
[英]I want to click on the <li> item in the left navigation of a webpage, using Python and Selenium webdriver to locate it
[英]Locate text in webpage and click - Eclipse Selenium
我想在网页中查找一些文本。 此文本位于列表中,对于此列表的每个值,我需要在网页中找到文本并单击属于该值的按钮。 这是我的代码:
List<String> lstFaturasAProcessar = new ArrayList<>();
for (String fatNumber : lstFaturasAProcessar) {
if(driver.getPageSource().contains(fatNumber))
driver.findElement(By.className("btn-default btn-small dropdown-trigger")).click();
}
基本上我是说,如果网页中存在该列表的值,请单击按钮。 list 的所有值都有不同的按钮,并且所有按钮都有相同的 class 名称,但是当它单击按钮时没有任何反应。 按钮的 HTML:
<button type="button" class="btn-default btn-small dropdown-trigger">
<span>Obter documentos<i class="icon2-arrow-down"></i></span>
</button>
你能帮助我吗?
对于某些角度/反应应用程序,请尝试单击跨度
例如:- //按钮/跨度并单击
你可以试试这个,用一些唯一标识符(如 I'd/name 等)获取此按钮的父级,然后尝试对要单击的匹配按钮执行 css 选择器,
示例:xpath:- //div[@id= 'blahblah'] / 按钮
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.