Handling various WebElement using WebDriver
Common Element Interactions
element.click();
element.sendKeys("text");
element.clear();
String text = element.getText();
boolean visible = element.isDisplayed();
Handling Dropdowns
Select dropdown = new Select(driver.findElement(By.id("country")));
dropdown.selectByVisibleText("India");
Handling Checkboxes and Radio Buttons
These are interacted with using click(), and their state can be checked with isSelected() before deciding whether to click.
PreviousIdentifying WebElement using id, name, linkText, partial LinkText, className, XPath, CssSelector and TagName
Next Handling Mouse movements and Keyboard Events
Ready to master real-world software testing?
Learn manual and automation testing hands-on with mentor-led sessions.
.png)