Selenium Java to select dropdown choice using selectByValue() method
KW.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 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/"); Thread.sleep(1000); Select country = new Select(driver.findElement(By.name("country"))); country.selectByValue("germany"); } }
Comments and Reactions
What Next?
Selenium Java for mouse events using the Action class
Selenium Java to perform series of multiple actions using Action and Actions classes
Selenium Java to select an option from the Chrome context menu
Advertisement