Selenium WebDriver
Benefits of Selenium
Four components of Selenium
Difference b/w Selenium IDE, RC & WebDriver
Selenium WebDriver Architecture
Background when user execute selenium code
Download and Install Java
Download and Install Eclipse
Download Selenium WebDriver
Selenium WebDriver Locators
Selenium - Launch Browser
Selenium WebDriver Waits
Selenium- Implicit wait
Selenium- Explicit wait
Selenium- Fluent wait
Selenium- Commonly used commands
Selenium- findElement & findElements
Selenium- Selenium-Handling check Box
Selenium- Handling Radio button
Selenium- Handling drop down
Selenium- Take Screenshot
Selenium- Handle Web Alerts
Selenium- Multiple Windows Handling
Selenium- Handle iframes
Selenium- Upload a file
Selenium- Download a file
Selenium- Actions Class Utilities
Selenium- Mouse Actions
Selenium- Keyboards Events
Selenium- Handle mouse hover Actions
Selenium- Drag and Drop
Selenium- Scroll a WebPage
Selenium- Context Click / Right Click
Selenium- Double Click
Selenium- Desired Capabilities
Selenium- Assertions
Selenium- Exceptions and Exception Handling
Selenium- Difference b/w driver.close() & driver.quit()
Selenium- difference b/w driver.get() & driver.navigate()
Selenium- JavascriptExecutor
Selenium- Read excel file using Fillo API
Selenium- Database Testing using Selenium
Selenium- Read & write excel file using Apache POI
Selenium- Read and Write csv file in Selenium
Selenium- Dynamic Web Table Handling
Selenium- Maven Integration with Selenium
Selenium- Set up Logging using Log4j
Selenium-Implement Extent Report
Handling Radio Button using Selenium WebDriver with Example
In this tutorial we will learn how to interact with radio button in selenium.
We can select or unselect radio buttons like checkbox using the click method .
We can select one radio button at a time.Â
We can also perform below checks before doing click operation on these
- Verify Radio button or Checkbox is displayed on the webpage
- Verify Radio button or Checkbox is enabled on the webpage
- Verify the default selection of the Radio button or Checkbox
Above scenarios can be verified using below predefined methods in selenium webdriver
- isDisplayed()
- isEnabled()
- isSelected()
Let’s take an exampleÂ
- Navigate to URL https://tutorialshut.com/demo-website-for-selenium-automation-practice/
- Verify above all the three scenarios for radio button ‘Male’ mentioned under Gender.
Below is the webElement for Male button
WebElement radioButtonMale = driver.findElement (By.id("male"));
All the three methods will return boolean values either true or False.
isDisplayed()
radioButtonMale.isDisplayed () ⇒ returns  true (Male radio button is present on the webpage ).
isEnabled()
radioButtonMale.isEnabled() == > returns true (Male radio button is enabled on the webpage)
isSelected()
radioButtonMale.isSelected() == > returns false (Male radio button is not already selected)
Now Let us understand how to interact with Radio button using below scenario
- Open the Chrome Browser
- Navigate to URL https://tutorialshut.com/demo-website-for-selenium-automation-practice/
- In Section ‘Radio buttons’’ ,Â
- Verify ‘Male’ radio button is displayed , Print the output of isDisplayed().
- Verify ‘Male’ radio button is enabled , Print the output of isEnabled().
- Choose ‘Male’ radio button
- Verify ‘Male’ radio button is selected , Print the output of isSelected().
- Close the browser.
Code Implementation
package com.test; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import junit.framework.Assert; public class HandlingRadioButton { public static WebDriver driver; public static void main(String[] args) throws InterruptedException { // Create a new instance of the Chrome driver System.setProperty("webdriver.chrome.driver", "D:\\Drivers\\chromedriver.exe"); driver = new ChromeDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // Launch the URL driver.get("https://tutorialshut.com/demo-website-for-selenium-automation-practice/"); // Maximize the window driver.manage().window().maximize(); WebElement radioButtonMale = driver.findElement(By.id("male")); // Verify ‘Male’ radio button is displayed , Print the output of // isDisplayed(). Boolean flagDisplay = radioButtonMale.isDisplayed(); Assert.assertTrue(flagDisplay); System.out.println("Male radio Button is displayed :" + flagDisplay); // Verify ‘Male’ radio button is enabled , Print the output of // isEnabled(). Boolean flagEnable = radioButtonMale.isEnabled(); Assert.assertTrue(flagEnable); System.out.println("Male radio Button is Enabled :" + flagEnable); // Choose ‘Male’ radio button radioButtonMale.click(); // Verify ‘Male’ radio button is selected , Print the output of // isSelected(). Boolean flagselected = radioButtonMale.isSelected(); Assert.assertTrue(flagselected); System.out.println("Male radio Button is Selected :" + flagselected); // close the driver driver.close(); } }
Selenium WebDriver Tutorials
Benefits of Selenium
Four components of Selenium
Difference b/w Selenium IDE, RC & WebDriver
Selenium WebDriver Architecture
Background when user execute selenium code
Download and Install Java
Download and Install Eclipse
Download Selenium WebDriver
Selenium WebDriver Locators
Selenium - Launch Browser
Selenium WebDriver Waits
Selenium- Implicit wait
Selenium- Explicit wait
Selenium- Fluent wait
Selenium- Commonly used commands
Selenium- findElement & findElements
Selenium- Selenium-Handling check Box
Selenium- Handling Radio button
Selenium- Handling drop down
Selenium- Take Screenshot
Selenium- Handle Web Alerts
Selenium- Multiple Windows Handling
Selenium- Handle iframes
Selenium- Upload a file
Selenium- Download a file
Selenium- Actions Class Utilities
Selenium- Mouse Actions
Selenium- Keyboards Events
Selenium- Handle mouse hover Actions
Selenium- Drag and Drop
Selenium- Scroll a WebPage
Selenium- Context Click / Right Click
Selenium- Double Click
Selenium- Desired Capabilities
Selenium- Assertions
Selenium- Exceptions and Exception Handling
Selenium- Difference b/w driver.close() & driver.quit()
Selenium- difference b/w driver.get() & driver.navigate()
Selenium- JavascriptExecutor
Selenium- Read excel file using Fillo API
Selenium- Database Testing using Selenium
Selenium- Read & write excel file using Apache POI
Selenium- Read and Write csv file in Selenium
Selenium- Dynamic Web Table Handling
Selenium- Maven Integration with Selenium
Selenium- Set up Logging using Log4j
Selenium-Implement Extent Report