出现报错Other element would receive the click:的原因是;
当你selenium中click()点击事件时,所选中的标签被外部div吸收了,因此
解决办法就是进入里面进行点击操作 。driver.execute_script("arguments[0].click();", lists[i])
Python执行script代码即可。
http://www.python66.com/bbs/221.html
调整后的代码运行的很流畅:
print("开始抓取%s第%s页..." % (self.searchkw , self.page_num)) try: nextbutton = self.driver.find_element(By.XPATH, '//nav[@role="navigation" and @aria-label="'+self.searchkw+' 的更多搜索结果"]//ul//li[last()]//a') #nextbutton.click() self.driver.execute_script("arguments[0].click();", nextbutton) except: nextbutton = self.driver.find_element(By.XPATH, '//ul[@class="sb_pagF"]//li[last()]//a') #nextbutton.click() self.driver.execute_script("arguments[0].click();", nextbutton)
转自:https://www.cnblogs.com/meblogs-08/p/16830156.html
标签:web,would,script,self,driver,nextbutton,报错,element,click From: https://www.cnblogs.com/xuxiaobo/p/17172872.html