In this segment, we will see how to connect with Radio Buttons. We can choose a radio catch alternative utilizing the 'click' strategy and unselect utilizing the equivalent 'click' technique.
Let us see how to cooperate with radio catches utilizing https://www.calculator.net/contract result calculator.html. We can likewise check if a radio catch is chosen or empowered.
Example
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class webdriverdemo {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
//Puts an Implicit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//Launch website
driver.navigate().to("http://www.calculator.net/mortgage-payoff-calculator.html");
driver.manage().window().maximize();
// Click on Radio Button
driver.findElement(By.id("cpayoff1")).click();
System.out.println("The Output of the IsSelected " +
driver.findElement(By.id("cpayoff1")).isSelected());
System.out.println("The Output of the IsEnabled " +
driver.findElement(By.id("cpayoff1")).isEnabled());
System.out.println("The Output of the IsDisplayed " +
driver.findElement(By.id("cpayoff1")).isDisplayed());
//Close the Browser.
driver.close();
}
}
Output
Upon execution, the radio catch is chosen and the yield of the orders are shown in the