Scrapy + Selenium + Datepicker

So I need to abandon the page, for example this, for example, and I use Scrapy + Seleninum to interact with the datepicker calendar, but I am running in ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with .

So far, I:

 def parse(self, response): self.driver.get("https://www.airbnb.pt/rooms/9315238") try: element = WebDriverWait(self.driver, 10).until( EC.presence_of_element_located((By.XPATH, "//input[@name='checkin']")) ) finally: x = self.driver.find_element_by_xpath("//input[@name='checkin']").click() import ipdb;ipdb.set_trace() self.driver.quit() 

I have seen some links on how to achieve this https://stackoverflow.com/a/464618/

I appreciate if someone can help me solve my problem or even provide a better example of how I can interact with this datepicker calendar.

+1
source share
1 answer

There are two elements with name="checkin" - the first one you actually find is invisible. You need to make your locator more specific so that it matches the desired input. Instead, I would use the condition visibility_of_element_located :

 element = WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located((By.CSS_SELECTOR, ".book-it-panel input[name=checkin]")) ) 
+1
source

Source: https://habr.com/ru/post/1244386/


All Articles