Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Which are the locators used for recognizing the objects in selenium webdriver

Selenium WebDriver can use these locators below when interacting with elements. 

 

  • Id
  • name
  • Link text
  • partial Link text
  • cssSelector
  • Xpath
  • tagname
  • class

 

 webDriver=new FirefoxDriver();  
     String URL="http://www.seleniummaster.com";   
     webDriver.get(URL);  //Navigate to URL
     webDriver.findElement(By.id("id"));
     webDriver.findElement(By.className("classname"));
     webDriver.findElement(By.cssSelector("cssSelector"));
     webDriver.findElement(By.partialLinkText("partialLinkText"));
     webDriver.findElement(By.linkText("linkText"));
     webDriver.findElement(By.name("name"));
     webDriver.findElement(By.tagName("tagname"));
     webDriver.findElement(By.xpath("//xpath"));