selenium.common.exceptions.ElementClickInterceptedException:消息:拦截了元素单击:(未单击元素。)

时间:2020-04-03 16:21:10

标签: selenium scrapy

我对python scrapy中的硒click()方法有疑问。我正在尝试将硒与草皮结合起来。

下面是我的代码。

import scrapy
from coroMap.items import CoromapItem
from selenium import webdriver 
from selenium.webdriver.common.keys import Keys



class MapSpider(scrapy.Spider):
    name = 'address' #spider's name
    start_urls = [ #start url
        "https://maps.vnpost.vn/corona/#/app"
    ]

    def __init__(self):
        scrapy.Spider.__init__(self)
        self.driver = webdriver.Chrome("C:/Users/aimclee/chromedriver")

    def parse(self, response): # self -> instance, response : response from request

        self.driver.get(response.url)
        self.driver.implicitly_wait(3)


        path = self.driver.find_elements_by_xpath('//*[@id="Capa_1"]')



        for address in path:
            # address.send_keys(Keys.ENTER) 
            address.click()
            # address.send_keys('\n')
            item = CoromapItem()
            item['address'] = response.css(".leaflet-popup-content div:nth-child(2)::text").extract() 
            self.driver.find_element_by_css_selector(".leaflet-popup-close-button").click()
            yield item

运行此代码时,错误消息如下:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted:


Element <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="50px" height="50px" id="Capa_1" x="0px" y="0px" viewBox="0 0 60 60" style="enable-background:new 0 0 60 60;" xml:space="preserve">...</svg> is not clickable at point (536, 
    698). 
Other element would receive the click: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="50px" height="50px" id="Capa_1" x="0px" y="0px" viewBox="0 0 60 60" style="enable-background:new 0 0 60 60;" xml:space="preserve">...</svg>
          (Session info: chrome=80.0.3987.149)

谢谢。

0 个答案:

没有答案