我在做硒webdriver。我有一些問題。如果我點擊瀏覽按鈕,然後應顯示popup.so我的應用程序不單擊和不打開瀏覽器。瀏覽器按鈕沒有點擊硒web驅動程序
try{
WebElement fileInput = driver.findElement(By.xpath("html/body/form[1]/p[2]/input"));
fileInput.sendKeys("C:\\Documents and Settings\\mahesh\\Desktop\\button then display msg.png");
System.out.println("valid");
}
catch(NoSuchElementException ex) {
System.err.println("invalid");
}
我得到了一個問題。
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"html/body/form[1]/p[2]/input"}
Command duration or timeout: 30.06 seconds
這種類型的錯誤來了。
所以請任何人指導我過來這個問題。
感謝 mahesh.k
Plz分享您的HTML代碼,以便我可以更具體地幫您 –
我想補充一點,在執行sendKeys()操作之前,最好使用.clear()方法清除輸入字段 –