刚开始接触python,大佬们勿喷
在自动化爬取某个网站,需要自动点击时出现元素覆盖的错误。
错误如下:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <h3 style="max-width: 180px;">...</h3> is not clickable at point (98, 653). Other element would receive the click: <img class="ad-logo" src="//www.lgstatic.com/lg-www-fed/common/widgets/un_login_banner/img/logo_41a2761.png" height="120" width="228">
(Session info: chrome=91.0.4472.124)
参照了网上大佬们的解决方法:
初始代码:
alst=web.find_elements_by_class_name('position_link')
for i in alst:
#找到h3并点击
i.find_element_by_tag_name("h3").click()(主要错误的地方)
改进后代码:
alst=web.find_elements_by_class_name('position_link')
for i in alst:
#找到h3并点击
element = a.find_element_by_tag_name("h3")
web.execute_script("arguments[0].click()",element)