选择确实选择下拉列表中的值,但不将值放在字段中。 below is the html
我正在使用:
Select companyList = new Select(createRequestPageObjects.company);
companyList.selectByVisibleText("PLACO");
Webelement在我的目标文件中定义:
@FindBy(xpath = "//label[contains(text(),'Société')]/following-sibling::div/select")
public WebElement company;
选择后,当我尝试打印时
System.out.println(companyList.getFirstSelectedOption().getText());
然后它会打印“PLACO”,但是在屏幕上它没有被选中,因为其他相关字段没有按要求获得列表值。
正如其他现有查询中所建议的那样,我尝试使用sendkeys
并尝试通过companyList.getOptions()
获取列表中的可能选项,然后在迭代时单击所需选项。似乎没什么用。