Sujan Prathi
Sujan Prathi

Reputation: 1

Selenium Firefox-Unable to locate an Web Element. Works on chrome and edge

I have a piece of code that works on Chrome and Edge but failing in Firefox browser. The page gets loaded but unable to identify a web element. Is there any step I should follow(like profile settings) while initializing the geckodriver? Need help in identifying the problem:

Code-

System.setProperty("webdriver.gecko.driver","<path>\geckodriver.exe");
private static WebDriver driver = new FirefoxDriver();

I tried locating the web element on firefox and its found on DOM. I have used implicitwait(). The page gets loaded and element visible. But somehow Firefox driver is not able to identify the element.

Upvotes: 0

Views: 102

Answers (1)

Shawn
Shawn

Reputation: 8508

In Java, single backslashes (\) are escape characters, so you need to use either double backslashes or a forward slash in the path.

Change your code as below:

System.setProperty("webdriver.gecko.driver","<path>\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();

Upvotes: 1

Related Questions