【发布时间】:2020-04-09 10:11:36
【问题描述】:
我试图关闭 whoscored.com 上的 cookie 按钮,我找到了该按钮,但是当程序点击时,它似乎点击了按钮后面的广告,并最终打开一个新页面而不是关闭 cookie 按钮.知道我能做什么吗?
url='https://www.whoscored.com/Search/?t=Crystal+Palace'
browse=webdriver.Chrome()
browse.get(url)
time.sleep(4)
cacheButton=browse.find_elements_by_xpath('//button')
cacheButton[1].click() #This is the "I ACCEPT" button.
这是按钮的html:
<button class="qc-cmp-button" onclick="window.__cmpui("setAndSaveAllConsent",!0)"> I accept </button>
如果有人可以帮助我,将不胜感激。
【问题讨论】:
标签: python selenium xpath selenium-chromedriver