Skip to main content

Selenium Locators


What are locaters in selenium 



  1. Locators in Selenium are one of the most required and important commands. Because they are building block of automation scripts 
  2. It helps to locate the GUI elements through which multiple user actions can be performed. 
  3. Using the right locator ensures the tests are faster, more reliable or has lower maintenance over releases
  4. Incorrect locators may lead to automation failure 



Types of locators



  • ID
  • Name
  • ClassName
  • Tag Name
  • Link Text and Partial Link Text 
  • CSS Selector 
  • Xpath 



Ways to find the locators in Browsers


  • Firepath, Firebug addons for firefox browser 
  • ChroPath
  • Direct method using f12 – developer tools 


How to pass the locators in Automation 


Locating elements in WebDriver is done by using the method
  • findElement(By.locator())
  • findElements(By.locator())


Watch the Tutorial on Youtube: 






Comments

Popular posts from this blog

Reading the data from a text file in Java and Selenium : There are two approaches where we can get the data from the text file that is file reader and buffered reader  this class allows us to get the data from the text file with the methods of its implementation like read() and readline() Code: Which can read the data character by character using the method read() public class filereader_character { public static void main(String[] args) throws Exception { FileReader reader = new FileReader("E:\\eclipseprojects\\Demoprojects\\seleniuminterviewQA\\testfile\\test.txt"); int character; while((character = reader.read()) != -1) { System.out.print((char) character); } reader.close(); } } Code: Which can read the data by string line using the method readline() public class filerreader_lines { public static void main(String[] args) throws IOException { FileReader reader1 = new FileReader("E:\\eclipseprojects\\Demoprojects\\seleniuminterviewQA\\testfil...

How to Handle Tooltips using selenium Webdriver.

Handling the tooltips are easy in selenium, we can achieve by using getAttribute("title"). where tooltips value is given in title attribute.  Do check out below code for implementation:   package SeleniumBasics; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; public class Seleniumtooltips {      public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "E:\\eclipseprojects\\seleniumDemo\\server\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("https://www.facebook.com/"); WebElement link1 = driver.findElement(By.linkText("Sign Up")); JavascriptExecutor scroll = (JavascriptExecutor) driver; scroll.executeScript("window.scroll...

How to write the defect report in software testing

 Defect report: In software testing its most important to find defects and let developer know about the defect. during this process of identifying the defect and reporting we need to follow some standard templates to report.  here is defect report template:  Refer the video for details: