Selenium Java to select dropdown choice using selectByValue() method
GD.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 GD { public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "/home/godarda/drivers/chromedriver"); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.navigate().to("https://godarda.com/testapp/"); Thread.sleep(1000); Select country = new Select(driver.findElement(By.name("country"))); country.selectByValue("germany"); } }
Comments and Reactions