[英]Finding elements in Selenium
My button looks like this: 我的按钮如下所示:
<button type="button" data-toggle="modal" data-target="#modal-order-export" data-backdrop="false" class="btn btn-default btn-sm">
<i class="fa fa-file-excel-o"></i> 엑셀 저장
</button>`
How can I click this object via selenium to automate some work? 如何通过硒单击该对象以自动执行某些工作? I tried:
我试过了:
driver.find_element_by_link_text('엑셀 저장').click()
You could take its xpath by right-clicking the element in developer tools and choosing copy. 您可以通过右键单击开发人员工具中的元素并选择复制来获取其xpath。 Then just find the element using xpath.
然后只需使用xpath查找元素。
The WebElement
which you are trying to search/find is within <button>
tag hence find_element_by_link_text
may not work. 您要搜索/查找的
WebElement
在<button>
标记内,因此find_element_by_link_text
可能不起作用。 We will be using an xpath
to locate the WebElement
as follows: 我们将使用
xpath
如下定位WebElement
:
driver.find_element_by_xpath("//button[@class='btn btn-default btn-sm']/i[@class='fa fa-file-excel-o']").click()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.