python-3.x - 无法定位元素(按钮)
问题描述
网站来源是:
<div id='product-touch'>
<div class='left">
<div class='space-a'>
<button class="button-buy">
<span> Add to basket</span>
</button>
</div>
</div>
</div>
我尝试使用以下代码行单击“添加到购物篮”按钮:
d.find_element_by_xpath("//div[@id='product-touch']/div/div/button").click()
但我得到:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate....
我需要对 XPATH 非常具体,因为在 div id="product-touch" 之前有另一个 div id 具有相同的按钮 class="button-buy"
有任何想法吗?
解决方案
推荐阅读
- mysql - MySQL:别名表不存在(复杂的子查询)
- ios - 解析 NSURL 方案 iOS
- angularjs - 日期过滤器导致 ng-repeat+其他过滤器在 IE11 中非常慢
- jakarta-ee - Java EE @ApplicationScoped 与单例模式
- node.js - Webpack + Typescript + watch 仅在重新编译时导致错误 TS2554
- upgrade - 向用户发送消息“产品已安装。卸载并安装新产品。” 使用安装盾
- android - 如何扫描支票的背面和正面
- javascript - SVG - 计算动态文本坐标
- json - Json解析字典中的数组
- postman - Restsharp vs Postman - 视频的内容类型