- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试从多选下拉框中进行选择,发现似乎是一个不错的资源。
我正在研究http://preview.harriscountyfws.org/我正在尝试在“按机构选择”多选下拉列表中选择多个项目。
我在这里向您展示的逻辑非常简单,并且遵循我找到的文章(如下所示),但我得到了 WebDriverException: Cannot click on option element。
对于获得有效的逻辑有什么建议吗?
逻辑如下:
WebElement we;
String searchText;
WebDriver driver;
Select select;
WebElement listbox_element;
listbox_element = driver.findElement(By.cssSelector("span[aria-owns='ddlRegion_listbox']"));
listbox_element.click();
driver = new FirefoxDriver();
driver.get("http://preview.harriscountyfws.org/");
searchText="ALL";
we = driver.findElement(By.id("ddlRegion"));
select = new Select(we);
select.selectByVisibleText(searchText);
引用号:http://www.techbeamers.com/dropdown-and-multiple-select-in-webdriver
最佳答案
我认为您没有找到正确的选择元素。您正在尝试的状态不是可见状态而是隐藏状态(可见:无)。
您需要找到“按机构搜索”下拉列表的箭头,找到该元素并单击它以使下拉列表可见。我不确定是否在 xpath 中包含 aria-owns 属性,但这是简单的方法。你可以看一下。
"//div[@id='searchDiv']//span[@aria-owns='ddlRegion_listbox']//span[@class='k-select']"
然后您需要等待 div[@id='regionSelectPopup'] 可见。将其粘贴到具有预期可见性条件的网络驱动程序等待中。
然后你可以在div中选择你想要的选项。我已经为所有人做了。您需要对其进行参数化。单击它。
"//div[@id='regionSelectPopup']//label[.='ALL']/preceding-sibling::input[@type='checkbox']"
它也可能适用于标签,但找不到复选框。
希望这能起作用。
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://preview.harriscountyfws.org/");
WebElement agencySearchSelect = driver.findElement(
By.xpath("//div[@id='searchDiv']//span[@aria-owns='ddlRegion_listbox']//span[@class='k-select']"));
agencySearchSelect.click();
new WebDriverWait(driver, 3, 100).until(ExpectedConditions.visibilityOfElementLocated(
By.id("regionSelectPopup")));
WebElement agencyOption = driver.findElement(
By.xpath("//div[@id='regionSelectPopup']//label[.='ALL']/preceding-sibling::input[@type='checkbox']"));
agencyOption.click();
关于java - Selenium Webdriver 多选下拉列表 ElementNotVisibleException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38921826/
此页面的主菜单( linio )有 11 个链接。只对 9 感兴趣(那些具有灰色背景并且悬停时显示子菜单的)。 我想从 9 个选项中单击子菜单中的每个元素。期望的过程是: 1.-第一部分:“Celul
我正在使用 Java selenium 自动输入用户的数据,但他必须通过下拉列表选择状态。我收到异常错误。 我尝试过使用所有选择器: drpState.selectByIndex(5); drpSta
我已经查看了涉及该主题的一些其他问题,但我没有在任何地方看到这个特定问题。我有一个点击 Web 元素的测试。我尝试通过 ID 和 XPath 引用它,并使用 wait.until() 等待它变得可见。
我正在尝试扩展所有评论、回复,在评论中查看更多内容,并在 Facebook 的帖子中查看更多内容。 1)我在下面编写的代码允许我扩展我想要的所有内容,除了帖子中的一些回复,即使我已将回复按钮放在循环中
我使用 EBays 的高级上传工具(URL:http://cgi5.ebay.com/ws/eBayISAPI.dll?NewListing&cpg=20&aid=1&from=wn&sid=5297
我看到很多关于 Selenium 的 ElementNotVisibleException 问题的问题/答案。到目前为止我完成的最好的代码如下: from selenium.webdriver.sup
我正在尝试使用 webdriver 单击链接,但它向我抛出一个 ElementNotVisibleException 说“元素当前不可见,因此可能无法与之交互” 我的网络驱动程序代码: addProg
import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import o
我正在使用 Selenium 和 Python,并且我正在尝试填写登录表单,我已经成功填写用户名字段,但无法填写密码。这是 HTML:
当我试图点击一个按钮时出现以下错误: org.openqa.selenium.ElementNotVisibleException: Element is not currently visible
我正在使用 Selenium Webdriver 登录网站。我尝试了多种不同的选择器,并尝试了隐式等待,但无法找到该元素。 from selenium import webdriver
我目前正在尝试使用 Selenium 进行一些用户界面测试,我遇到了这个很好的方法(不确定我从哪里得到它......),它应该处理不存在的元素和隐藏元素...... 问题在于第二个问题:即使元素未显示
我正在尝试使用我正在使用的 Selenium 进行黑盒测试: Mac 操作系统:版本:10.9.4 java.版本:1.6.0_65 浏览器:firefox 版本 32.0.3 Selenium :版
尝试从多选下拉框中进行选择,发现似乎是一个不错的资源。 我正在研究http://preview.harriscountyfws.org/我正在尝试在“按机构选择”多选下拉列表中选择多个项目。 我在这里
我想做的就是:转到“http://news.google.com”,然后单击侧面菜单上的“技术”链接。这是我的代码: from selenium import webdriver from selen
目前我有此输入 + Add certificate 并且我想将文件发送到同一地址,因此我运行以下代码: self.driver.execute_script("docu
我试图让 selenium 单击 li 元素内的链接。这是在 while 循环内发生的。点击一直有效,直到我到达 li 低于 Firefox 窗口的水平。如果我在 selenium 尝试点击之前在 F
我有一个帮助函数来浏览页面并打开它找到的每个帮助按钮。它既漂亮又简单; def openHelp(ff): """ Opens all the help buttons on the
我正在尝试以编程方式在网站中选择一种货币:http://www.asos.com/asos/asos-skinny-chinos-in-dark-khaki/prd/5542109 但是它给我带来了一
我从来没有认真研究过 HTML,所以我要说的可能是不对的。 当我编写 selenium 代码时,我注意到某些网页上的某些按钮不会重定向到其他页面,但它们会更改第一个页面的结构。据我了解,发生这种情况是
我是一名优秀的程序员,十分优秀!