Selenium Java to select dropdown choice using selectByValue() method
Codeaft.java
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.Select; class Codeaft { public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "/home/codeaft/drivers/chromedriver"); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.navigate().to("https://codeaft.github.io/testapp/"); Thread.sleep(1000); Select country = new Select(driver.findElement(By.name("country"))); country.selectByValue("germany"); } }
Comments and Reactions