简体   繁体   English

从下拉列表中选择Selenium Java

[英]Selecting from drop down list Selenium Java

This is part of website code related to this question 这是与此问题相关的网站代码的一部分 这是与此问题相关的网站代码的一部分

I have trouble here to identify drop down list, actually i cant find a xpath of this drop down element and select first (and only) element from drop down list. 我在这里很难确定下拉列表,实际上我找不到此下拉元素的xpath并从下拉列表中选择第一个(也是唯一一个)元素。

driver.findElement(By.xpath("//input[@placeholder='Assign to a member']"));

This is my xpath for field, but nothing happens when start working. 这是我的字段的xpath,但是开始工作时什么也没发生。 Anyone to suggest me how to approach to this issue. 有人建议我如何处理此问题。

in Java, you need to create a select element to choose the options of the select. 在Java中,您需要创建一个select元素来选择select的选项。

The code will be somenthing like: 该代码将是这样的:

WebElement element = driver.findElement(By.xpath("//input[@placeholder='Assign to a member']"));

String option = "Option value you want to select";
Select select = new Select(element);
select.selectByVisibleText(option);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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