【发布时间】:2017-08-03 08:55:01
【问题描述】:
我正在使用 selenium(python) 进行网络抓取。代码中有很长的块。所以,我正在使用循环。当我单独运行代码行时,它工作正常,但是当我使用循环时,它不起作用。以下是两个错误:
WebDriverException: Message: unknown error: Element is not clickable at point (862, 13). Other element would receive the click: <div class="skycom_container">...</div>
(Session info: chrome=46.0.2490.80)
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64)
WebDriverException: Message: unknown error: Element is not clickable at point (924, 786). Other element would receive the click: <div id="silentUIblocker" style="display: block;"></div>
(Session info: chrome=46.0.2490.80)
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64)
这些是常见的还是特定的错误? 这发生在使用 click() 语句之前。
这是我的代码:
from selenium import webdriver
import time
driver = webdriver.Chrome('C:\Users\name\Downloads\chromedriver_win32 (3)\chromedriver.exe')
driver.get('https://www.sky.com/shop/beta?s_tnt=87085:31:0')
driver.find_element_by_xpath('//*[@id="app"]/div/div/div[2]/div/div[5]/article/button/div[1]/div[2]/div/h2').click()
driver.find_element_by_xpath('//*[@id="app"]/div/div/div[2]/div/div[6]/section/div/div/div/div/div[1]/article/a').click()
driver.find_element_by_xpath('//*[@id="polaris"]/div/div/div/section/div/div[2]/a[2]').click()
driver.find_element_by_xpath('//*[@id="dsl-postcode"]').send_keys("E11 2LX")
driver.find_element_by_xpath('//*[@id="dsl-check-landline"]').click()
driver.find_element_by_xpath('//*[@id="dsl-addresses"]/option[2]').click()
driver.find_element_by_xpath('//*[@id="dsl-multiple-address-select"]').click()
driver.find_element_by_xpath('//*[@id="dsl-numberPortingNo"]').click()
driver.find_element_by_xpath('//*[@id="dsl-number-porting-submit"]').click()
driver.find_element_by_xpath('//*[@id="summaryBackLink"]').click()
driver.find_element_by_xpath('//*[@id="oneOffCostToolTip"]').click()
bb_pack = ["SKY_FIBRE_CAPPED", "BB_MAX"]
for i in bb_pack:
driver.find_element_by_xpath('//*[@id="productButtonControls_%s"]/label' % i).click()
bb_name1.append(driver.find_element_by_xpath('//*[@id="productButtonControls_%s"]/label' % i).text)
pack = ["ANYTIME_EXTRA", "INTERNATIONAL_EXTRA"]
for j in pack:
driver.find_element_by_xpath('//*[@id="productButtonControls_ST_%s"]/label' % j).click()
bb_name2.append(driver.find_element_by_xpath('//*[@id="productButtonControls_ST_%s"]/label' % j).text)
#more details in this loop
【问题讨论】:
-
考虑将您的
Chrome升级到 60.0 和chromedriver到 2.30。谢谢 -
这通常发生在 Dom 正在更新并且 webdriver 尝试单击或另一个隐藏元素阻止您的元素时。尝试在点击之间等待/休眠。
-
@Debanjan,升级对我来说根本不是一个选择。
-
@Prakash,我试过了,我有将近 400 个这样的案例,应用睡眠需要很长时间。还有其他选择吗?
标签: python selenium web-scraping automation