I have written selenium webdriver test and want o test back and forward options of browser. My code is
@Test
public void testBrowserHistory() throws Exception
{
//Load web page
d.navigate().to("
http://docs.seleniumhq.org/");
assertEquals("Selenium - Web Browser Automation",d.getTitle());
//Click on Download Tab
d.findElement(By.linkText("Download")).click();
System.out.println(d.getCurrentUrl());
d.navigate().back();
System.out.println(d.getCurrentUrl());
d.navigate().forward();
System.out.println(d.getCurrentUrl());
d.navigate().refresh();
System.out.println(d.getCurrentUrl());
}
@Before
public void setUp()
{
//Launch browser
System.setProperty("webdriver.gecko.driver", "C://Selenium driver/geckodriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
d=new FirefoxDriver();
d.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);
d.manage().deleteAllCookies();
}
@After
public void tearDown()
{
//Close browser
d.quit();
}
}
The output is
http://docs.seleniumhq.org/
http://docs.seleniumhq.org/
http://docs.seleniumhq.org/
http://docs.seleniumhq.org/
The browser does not go to download page. What is the problem.