selenium.common.exceptions.ElementClickInterceptedException: Сообщение: щелчок элемента перехвачен: (элемент не нажат). - PullRequest
0 голосов
/ 03 апреля 2020

У меня проблема с селеновым щелчком () в python scrapy . Я пытаюсь интегрировать селен со скрапом.

Ниже мой код.

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)

Заранее спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...