Since the selenium work on the DOM model its important have the knowledge of the element locator in Selenium. Selenium provides a variety of selector.
These are the selector provided by the Selenium to locating object. Effect uses of these are required when we write the code for test. Consider the scenario we want check the hyperlinks in a page of a website. For that we can use the locator to identify the link and click on it. As I mentioned earlier a HTML tag contain any of the above listed attribute. By giving the name with in the double quote we can select the element.
- driver.findElement(By.xpath(".//*[@id='c).click();
- driver.findElement(By.linkText("Java")).click();
- driver.findElement(By.name("User")).click();
- driver.findElement(By.Id("User")).click();
Similarly the rest of the selectors are easily understood. These selectors are the basic building blocks of the test suite
BEST PRACTICE
Knowing the basic of JAVA will be good for the programming, such as importing packages accessing methods and parametrize, while writing the code one of the key thing to consider is the code re usability. Following a framework will be good for the code re usability.
No comments:
Post a Comment