【发布时间】:2015-09-18 04:42:03
【问题描述】:
我有如下按钮详细信息。
<button type="button" class="add-to-cart button primary-button false item-action-button">
Add to Cart
</button>
而xpath是/html/body/div/div[2]/div[2]/div/div[4]/div/div[1]/button
如何点击按钮?
我试过用这个find_element_by_xpath('/button[contains(text(), "Add to Cart")]')
但它不起作用。我不想只在给定的 xpath 上执行 .click() 。有没有办法通过查找文字点击?
我正在使用 python 实现自动化
【问题讨论】:
标签: python-2.7 selenium selenium-webdriver selenium-chromedriver