0
我想用selenium webdriver测试GWT web应用程序。我想获取gwt组合框选定选项的值。可以请别人告诉我,我该怎么做。 感谢如何使用硒web驱动程序获取gwt combobox的值?
我想用selenium webdriver测试GWT web应用程序。我想获取gwt组合框选定选项的值。可以请别人告诉我,我该怎么做。 感谢如何使用硒web驱动程序获取gwt combobox的值?
选择可以查看值,如下面给出的 -
Select combo1 = new Select(driver.findElement(By.xpath("xpath of combobox")));
WebElement comboOptionSelected = combo1.getFirstSelectedOption();
System.out.println("Selected option is " + comboOptionSelected.getText());
如果你想获取从组合框中选择的选项按照下面的一个。
Select dropdown = new Select(driver.findElement(By.id("dropDownElementID")));
WebElement option = dropdown.getFirstSelectedOption();
option.getText();
如果你想选择一个值使用下面的值。
dropdown.selectByVisibleText("text");
试试代码并让我知道结果。
请分享你的代码以及你有什么尝试?? –
你是什么意思的价值..选项的价值或可见选项的文本?? .. –