[英]Unable to right click in firefox browser using selenium (java) automation
[英]Unable to go for next Annotation of selenium browser automation with simple java codes
我要做的是使Firefox瀏覽器自動化以在搜索欄中搜索項目。 我的Java代碼如下。
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FlipkartTest {
public static void main(String[] args) {
CharSequence[] cs = {"Dell"};
//CharSequence[] d = String[]{"Dell"};
//String s = toString();
WebDriver driver = new FirefoxDriver();
driver.get("http://www.flipkart.com");
driver.findElement(By.id("fk-top-search-box")).sendKeys(cs);
driver.findElement(By.xpath("//input[@value=Search]")).click();
}
}
調試或運行代碼后,將出現一個新的Firefox窗口,但是單擊下一個“注釋”按鈕時,沒有任何反應。 它不會繼續進行下一步,例如打開Flipcart.com網站或搜索單詞。
運行代碼后,控制台將顯示一個列表。 我從中找到這條線。
Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.
那我該如何解決這個問題呢?
正如這里所回答的,問題在於selenium
和Firefox
之間不匹配。 將它們更新到最新版本應該可以解決該問題。
我建議您首先設置Firefox驅動程序的屬性,然后創建它的實例。 像這樣-
Webdriver driver=null;
System.setProperty("webdriver.firefox.driver"."//your firefox driver path");
driver=new FirefoxDriver();
另外,嘗試使用ChromeDriver和InternetExplorerDriver,並檢查問題是否仍然存在。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.