Navigation on Same Tab

package seleniumOperations;


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class Navigation
{
public static void main(String a[]) throws InterruptedException
{


       WebDriver driver = new FirefoxDriver();
       String URL="http://selenium-code.blogspot.in/";
            driver.get(URL);

            /*1. return type of findElement() method is WebElement
               2. use firebug and firepath combination to findout the xpath of webelement
            */
            WebElement link=driver.findElement(By.xpath(".//*[@id='BlogArchive1_ArchiveList']/ul/li/ul/li/ul/li[2]/a");
         
         
            Thread.sleep(2000);
            //Navigate again on Same Page
         
            driver.navigate().back();
     
     
}

}


or

driver.navigate().forward(); // for Forward Navigation

Post a Comment

0 Comments