源代码:
...省略
loc = driver.find_element_by_xpath("//div[@class='sidebar-btn yellow']/div/i")
loc.click()
报错如下:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <i class="si icon-addpages"></i> is not clickable at point (34, 141). Other element would receive the click: <div id="topMask" style="position: fixed; top: 0px; left: 0px; bottom: 0px; right: 0px; z-index: 9999999999999;"></div>
(Session info: chrome=75.0.3770.142)
修改代码:
#方法一:
loc = driver.find_element_by_xpath("//div[@class='sidebar-btn yellow']/div/i")
driver.execute_script("arguments[0].click();", loc)
#方法二:
loc = driver.find_element_by_xpath("//div[@class='sidebar-btn yellow']/div/i")
webdriver.ActionChains(driver).move_to_element(loc).click(loc).perform()
完美解决。。。