Selenium Java to select the radio button using cssSelector
KW.java
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

class KW
{
    public static void main(String[] args) throws InterruptedException 
    {   
        System.setProperty("webdriver.chrome.driver", "/home/kodingwindow/drivers/chromedriver");
        WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.navigate().to("https://kodingwindow.com/testapp/");
        driver.findElement(By.name("username")).sendKeys("kodignwindow");
        Thread.sleep(1000);
        driver.findElement(By.name("password")).sendKeys("kodignwindow");
        driver.findElement(By.cssSelector("input[name='usertype'][id='admin']")).click();
    }
}
What Next?
Selenium XPath
Advertisement