SeanDaBlack / KelloggBot

Kellogg bad | Union good | Support strike funds
GNU General Public License v3.0
398 stars 81 forks source link

Invalid Session ID After Running for a While #38

Closed joeyagreco closed 1 month ago

joeyagreco commented 2 years ago

`FAILED TO START DRIVER: Message: element not interactable: element has zero size (Session info: chrome=96.0.4664.93)

Traceback (most recent call last): File "C:\Users\14143\PycharmProjects\KelloggBot\main.py", line 285, in main fill_out_application_and_submit(driver, random_city, fake_identity) File "C:\Users\14143\PycharmProjects\KelloggBot\main.py", line 166, in fill_out_application_and_submit driver.implicitly_wait(10) File "C:\Users\14143\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 911, in implicitly_wait self.execute(Command.SET_TIMEOUTS, { File "C:\Users\14143\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\14143\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\14143\PycharmProjects\KelloggBot\main.py", line 297, in main() File "C:\Users\14143\PycharmProjects\KelloggBot\main.py", line 289, in main driver.close() File "C:\Users\14143\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 688, in close self.execute(Command.CLOSE) File "C:\Users\14143\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\14143\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id

FAILED TO CREATE ACCOUNT: Message: invalid session id

FAILED TO FILL OUT APPLICATION AND SUBMIT: Message: invalid session id

Process finished with exit code 1 `

bolshoytoster commented 2 years ago

This stackoverflow question seems related:

The root cause of that issue is that Chrome doesn't scroll to the element outside of the viewport.

It is definitely an issue with Chrome 83 because I didn't face it on Chrome 81.

We should scroll to the element before clicking using something like:

driver.executeScript("arguments[0].scrollIntoView(true);", element)

Before clicking anything off-screen.

bolshoytoster commented 2 years ago

Looking into the stack trace, it looks like the error comes from driver.implicitly_wait(10), which is strange.

In my branch (https://github.com/bolshoytoster/KelloggBot), I use WebDriverWait instead, you could try using that instead until my pr gets merged.

Jaysyn904 commented 2 years ago

Came here to post this error as well.

successfully submitted application failed to start driver: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="page_content"]/div[2]/div/div/div[2]/div/div/div[2]/a"} (Session info: chrome=96.0.4664.93)

Traceback (most recent call last): File "req.py", line 415, in main driver = start_driver(rand_num) File "req.py", line 220, in start_driver driver.find_element_by_xpath( File "/home/jason/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/home/jason/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { File "/home/jason/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/jason/.local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="page_content"]/div[2]/div/div/div[2]/div/div/div[2]/a"} (Session info: chrome=96.0.4664.93)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "req.py", line 441, in main() File "req.py", line 418, in main driver.close() File "/home/jason/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 688, in close self.execute(Command.CLOSE) File "/home/jason/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/jason/.local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id

bolshoytoster commented 2 years ago

@Jaysyn904 Your error is separate, it's when it tries to click something that hasn't loaded yet. This is fixed on my fork (https://github.com/bolshoytoster/KelloggBot) if you can clone that instead.