Python selenium 通过背景渐变查找元素

标签 python css selenium xpath background

以前我发现过这样的元素:

element = fox.find_element_by_xpath("//div[contains(@class, 'well')]/p[2]/a[@style='background:#0373F1;']")

效果很好!但现在元素有一个渐变:

"background:transparent linear-gradient(to bottom, #31A61A 0%, #217510 100%) repeat scroll 0% 0%"

我怎样才能做到这一点?

最佳答案

请尝试以下 xpath。应该可以工作

element = fox.find_element_by_xpath("//div[contains(@class, 'well')]/p[2]/a[contains(@style,'background:transparent linear-gradient')]")

关于Python selenium 通过背景渐变查找元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32813162/

相关文章:

python - 分段函数不起作用

html - Iphone 7 Safari 文本跳转问题

html - 如何在 <p> 标签中的单词之间添加间距并将它们与下一个 div 中的文本框对齐

selenium - Selenium 中的 "clickable"元素是否也意味着它是 "visible and present"?

python - 如何用 pypy 运行 ipython?

python - 如何使用pycharm连接spark和mysql

python - 如何在 django 中强制出现异常以便在 django 中对其进行测试

css - 仅使用 chrome 的列和页脚之间的大空间

基于Java的selenium webdriver - 单击按行文本动态更改表格内容中的元素(单击同一行中的文本输入)

c# - 无法使用 C# 在 Selenium WebDriver 中使用现有的 Firefox 配置文件