以前我发现过这样的元素:
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/