python - Message: Element is not visible - Selenium error happens randomly -


i'm working on side project monitor flight prices i'm getting error message: element not visible only. weird thing error not thrown every time , cannot manage figure out causes it. tried adding implicit wait incase page hasn't loaded didn't help. page loads google flights , error happens when tries send text destination city.

import time selenium import webdriver  selenium.webdriver.common.keys import keys selenium.webdriver.common.by import selenium.webdriver.support.ui import webdriverwait selenium.webdriver.support import expected_conditions ec  class bot:      def __init__(self):         self.browser = webdriver.firefox(executable_path='./geckodriver')         # self.browser = webdriver.chrome('./chromedriver')         self.departure_city = "cou"         self.destination_city = "hnd"         self.departure_day = "december 1"         self.return_day = "december 10"         self.prices = []         self.run()      def run(self):         try:             self.setflight()             self.setdates()             self.findprices()             self.sendtext()         except exception ex:             print(ex)             self.browser.quit()      def setflight(self):         self.browser.get('https://www.google.com/flights/');         departure_take_off_boxes = self.browser.execute_script(              "return document.queryselectorall('.eigtdnc-kb-f.eigtdnc-kb-b')")         # print(departure_take_off_boxes[0].get_attribute('outerhtml'))         # print(departure_take_off_boxes[1].get_attribute('outerhtml'))         departure_take_off_boxes[0].send_keys(self.departure_city)         departure_take_off_boxes[0].send_keys(keys.return)         time.sleep(1)         self.browser.implicitly_wait(10)         departure_take_off_boxes[1].send_keys(self.destination_city)         departure_take_off_boxes[1].send_keys(keys.return)         time.sleep(1) 


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -