SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

Selenium WebDriver : How To Navigate URL, Forward and Backward With Example

In my earlier posts, we have learnt few BASIC ACTION COMMANDS of selenium WebDriver software testing tool with examples. You will have to use them on daily basis for you software web application's webdriver test case preparation. It is very important for you to use them on right time and right place. Now let we learn 3 more action commands of webdriver.

1. driver.navigate().to
If you wants to navigate on specific software web application page or URL in between your software test then you can use driver.navigate().to command as bellow.
driver.navigate().to("http://only-testing-blog.blogspot.com/2014/01/textbox.html");

2. driver.navigate().back();
This command is useful to go back on previous page. Same as we are clicking browser back button. You can use this command as bellow. In Selenium IDE software testing tool, we can use "goBack" to perform same action.
driver.navigate().back();

3. driver.navigate().forward();
Same as we are clicking on forward button of browser

Bellow given example will cover all three commands. Execute it in your eclipse to know them practically.

Copy bellow given @Test method part of driver.navigate() command examples and replace it with the @Test method part of example given on THIS PAGE(Note : @Test method is marked with pink color in that linked page).
@Test
 public void test () throws InterruptedException 
 { 
  driver.navigate().to("http://only-testing-blog.blogspot.in/2014/01/textbox.html");

  //To navigate back (Same as clicking on browser back button)
  driver.navigate().back();

  //To navigate forward (Same as clicking on browser forward button)
  driver.navigate().forward();
 }

3 comments:

  1. Thanks for the useful post.

    ReplyDelete
  2. sir plz send me example of radio button and check box button in selenium in java....plz.....i take example of http://www.spicejet.com/

    ReplyDelete
  3. Komal Thakkar you can you Xpath absolute your given site url i had check and you radio button xpath is

    driver.findElemnt(By.xpath("/html/body/form/div[4]/div[2]/div/div[4]/div[2]/div[1]/div[2]/div[2]/div/div[1]/table/tbody/tr/td[2]/input")).clik();

    ReplyDelete