Selenium Java to select dropdown choice using selectByVisibleText() 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/"); driver.findElement(By.name("username")).sendKeys("USERNAME"); Thread.sleep(1000); driver.findElement(By.name("username")).clear(); Select country = new Select(driver.findElement(By.name("country"))); country.selectByVisibleText("Germany"); } }
Comments and Reactions
What Next?
Selenium Java to select dropdown choice using selectByIndex() method
Selenium Java to select dropdown choice using selectByValue() method
Selenium Java for mouse events using the Action class
Advertisement