I’m encountering an issue with a Flask application that uses Selenium WebDriver to log in to a website using cookies. The application works perfectly on my local test server, but when I deploy it to AWS Elastic Beanstalk, the WebDriver quits unexpectedly without any error message. Instead of taking a screenshot of the page, the driver quits and the program stalls.
The program successfully navigates to the site, adds the cookies I want, but upon a refresh, the the driver seems to stall out.
Note that WEBSITE here is a placeholder.
Code snippet:
def login(self):
time.sleep(2)
self.driver.get(WEBSITE)
before_cookies = self.driver.get_screenshot_as_base64()
logging.debug(before_cookies)
time.sleep(1)
self.add_cookies()
after_cookies = self.driver.get_screenshot_as_base64()
logging.debug(after_cookies)
time.sleep(2)
self.driver.refresh() #This is where it seems to quit. I don't get the 'refresh_64' screenshot in the log file.
time.sleep(2)
refresh_64 = self.driver.get_screenshot_as_base64()
logging.debug(refresh_64)
Relevant log file output:
long string (base 64 of 'after_cookies' screenshot)
2024-07-18 21:17:42,429 DEBUG: POST http://localhost:35951/session/e0e3a47dbdf86bbb8365d1158af73/url {'url': WEBSITE}
Environment details
- Local: macOS (Sonoma 14.5)
- AWS EB: Amazon Linux 2023
- ChromeDriver version 126.0.6478.126
- Selenium version: 4.22.0
Thank you!
Evan Taylor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.