简体   繁体   中英

Dropdown missing final click

Guys could someone please assist me to finish following: I need to open dropdown and choose option. My code is:

WebElement sorter = driver.findElement(By.cssSelector(".column.medium-12 .row"));
    sorter.click();
    Actions keyDown = new Actions(driver);
    keyDown.sendKeys(Keys.chord(Keys.DOWN)).perform();

I use following since there is no other way to open dropdown. After above code finishes, it looks like as on screenshot (stuck on first chosen option without confirmation). I am actually missing confirmation click but could not find solution. Please assist, thank you in advance.

在此处输入图片说明

I'm guessing that the drowdown is just a normal <select> html element.

If that's the case, then you can iterate over the <option> elements of the drowdown and select the first.

WebElement sorter = driver.findElement(By.cssSelector(".column.medium-12 .row"));
sorter.click();
List<WebElement> elements = sorter.findElements(By.tagName("option");
WebElement option = elements.get(0);
option.click();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM