Selenium Notes 09062021
Selenium Notes 09062021
we can access webdriver methods by using chromedriver class instantiate like below:
driver.findElement(By.id("lst-ib")).sendKeys("Java Tutorials");
The clear() method is used to clear the user inputs from the text box.
driver.findElement(By.name("q")).clear();
Sometimes we need to fetch the text written over a web element for performing some
assertions and debugging. We use getText() method to fetch data written over any
web element.
driver.findElement(By.id("element567")).getText();
The click() method is used to perform click operation on any web element.
driver.findElement(By.id("btnK")).click();
9. Closing Browser
driver.close();
10. Closing Browser and other all other windows associated with the driver
driver.quit();
WebDriver uses the same set of locating strategies for specifying location of a
particular web element.
The 'Select' class in Selenium WebDriver is used for selecting and deselecting
option in a dropdown. The objects of Select type can be initialized by passing the
dropdown webElement as parameter to its constructor.
WebDriver provides three ways to select an option from the drop-down menu.
1. selectByIndex - It is used to select an option based on its index, beginning
with 0.
dropdown.selectByIndex(5);
2. selectByValue - It is used to select an option based on its 'value' attribute.
dropdown.selectByValue("Database");
3. selectByVisibleText - It is used to select an option based on the text over the
option.
dropdown.selectByVisibleText("Database Testing");