代码:
# 3.2 定位节点
ele=driver.find_element_by_xpath('//ul[@class="m-cvrlst f-cb"]/li/p/a')
# 3.3 模拟点击
ele.click()
发生异常:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <iframe name="contentFrame" id="g_iframe" class="g-iframe" scrolling="auto" frameborder="0" src="about:blank" allowfullscreen="true" cd_frame_id_="9df25c30d23c193344fae23a89222cdb"></iframe> is not clickable at point (109, 632). Other element would receive the click: <div class="btns">...</div>
(Session info: chrome=90.0.4430.93)
原因:应该是元素定位相互覆盖。
解决:将单击修改成js
driver.execute_script("arguments[0].click();", ele)