我正在尝试使用selenium查找(并单击)Python程序的特定页面。
我试过了
driver.findElement(By.cssSelector("a[href*='text']")).click();
以及
driver.findElement(By.partialLinkText("text")).click();
用我正在寻找的东西。这些不适用于错误
AttributeError: 'WebDriver' object has no attribute 'findElement'
我只能假设它找不到元素,因为这是Java的,不是Python的。
网站上链接的唯一区别因素是href属性。
所有其他标签都有重复。我不可能百分之百地猜测正确的链接,所以我还需要定位器是由部分文本。
有什么办法开始吗?我可以用其他程序吗?有人成功地做到了吗?我试过找,但没人问这个。
您可以尝试:
或者
编辑:若要在href本身上进行部分文本搜索,请尝试:
资料来源:
http://selenium-python.readthedocs.org/faq.html?highlight=click#how-to-auto-save-files-using-custom-firefox-profile
http://selenium-python.readthedocs.org/locating-elements.html#locating-elements
相关问题 更多 >
编程相关推荐