Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
package testCode;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Testcode2 {

public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver","C://Program Files (x86)//geckodriver-v0.11.1-win64//geckodriver.exe");
WebDriver driver = new FirefoxDriver();
String URL = "http://www.demoqa.com";
driver.get(URL);
driver.findElement(By.xpath(".//*[@id=’menu-item-374′]/a")).click();
driver.navigate().back();
driver.navigate().forward();
driver.navigate().to(URL);
driver.navigate().refresh();
driver.quit();
}
}

While testing this code, back, forward, to and refresh commands didnt work and it closed the browser…..any issues with the code

Firefox version is 45.0.2 and when i checked the code line wise i found that after clicking the XPATH link mentioned, it does not click back, forward links but the to (URL) and refresh code is executed in a flash of a second. Any suggestions !!!!!!!!!!!!

What I have tried:

I tried the implicitwait function to check if after waiting for few secs it will perform those tasks which i have mentioned, didnt work otherwise.
Posted
Updated 5-Jul-17 1:11am
v2

This code need sometime to execute, because it is multithreading. Work with timer callbacks to execute each code piece. Some waiting around 2 to 10 seconds would be my first guess.

Some examples how to run and work with timeouts.
 
Share this answer
 
I have already tried implict wait function but it didnt work either.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900