Content ITV PRO
This is Itvedant Content department
Use this slide if there is no Heading
Note - Create Content inside Red Layout
[Delete Red Outline After creating slide]
Learning Outcome
5
Handle common UI automation challenges for reliable tests
4
Work with dropdowns, checkboxes, and radio buttons
3
Identify element states such as visible, enabled, and selected
2
Perform basic actions like click, type, clear, and read data
1
Understand how to interact with web elements in automation
Topic Name-Recall(Slide3)
Hook/Story/Analogy(Slide 4)
Transition from Analogy to Technical Concept(Slide 5)
Core Actions: Click, Type, Clear, Read
sendKeys("value")
Enters text into input fields and text areas
Retrieves visible text or hidden attribute values
getText() / getAttribute()
clear()
Performs a click on buttons, links, and other clickable elements
click()
Removes existing text from input fields before typing
Core Actions: Click, Type, Clear, Read
findElements(By locator)
Returns a list of all matching elements
driver.get("https://example.com/");
String title = driver.getTitle();
Opens the specified web page in the browser
get(String URL)
WebElement List links = driver.findElements(By.tagName("a"));
Finds and returns the first matching
findElement(By locator)
1
2
3
Core Actions: Click, Type, Clear, Read
close()
Closes the current browser window
driver.close();
driver.quit();
Closes all browser windows and safely ends the session
quit()
String title = driver.getTitle();
Returns the title of the current page
getTitle()
5
4
6
Know Before You Act: Element StateMethods
Returns true if the element is visible on the page
if(element.isDisplayed()) { element.click(); }
isDisplayed()
Returns true if the element can be interacted with
// Disable login until form valid loginBtn.isEnabled() ? "Ready" : "Complete form"
isEnabled()
Returns true if checkbox or radio button is selected
if(!termsCheckbox.isSelected()) {termsCheckbox.click(); }
isSelected()
Working with Selectable Inputs
Perform Action
Verify Result
Use isSelected() to determine if an element is already checked
Check again with isSelected() to confirm the change occurred
Click to toggle state based on your verification
Check Current State
Using the Select Class for Dropdowns
Selection Methods
getFirstSelectedOption() - Current selectio
Retrieving Options
selectByValue("IN")
// Create Select object Select dropdown = new Select( driver.findElement(By.id("cou ntry")));Select Class Initialization
​selectByIndex(2)
selectByVisibleText("India")
getOptions() - All available options
getAllSelectedOptions() - For multi-select
Troubleshooting Real-World UI Issues
Stale Element Exception
Occurs when the DOM changes and referenced elements become invalid
Re-locate Elements
Find elements again after page changes instead of reusing references
Implement Waits
Use explicit waits to handle dynamic content and AJAX calls
Use Flexible Locators
XPath with contains() and starts-with() handles dynamic IDs
Interact with Confidence: Key Takeaways
1. Validate Before
2. Use Specialized Tools
3. Anticipate Challenges
Prepare for stale elements and timing issues
4. Build Resilient Test
Summary
5
andling issues like dynamic elements makes automation more reliable
4
Special tools like dropdown handling improve interaction accuracy
3
Element state methods help verify before performing actions
2
WebDriver provides methods to locate and control elements
1
WebElement methods help interact with UI elements on web pages
Quiz
Which method checks if an element is visible on the page?
A. isEnabled()
B. isDisplayed()
C. isSelected()
D. isVisible()
Quiz-Answer
Which method checks if an element is visible on the page?
A. isEnabled()
B. isDisplayed()
C. isSelected()
D. isVisible()
By Content ITV