Reputation: 1
I am running a python script that implements selenium and geckodriver to login to a website account. The code works locally in a container with no problems, however when I deploy it to AWS-batch it stops working reliably.
I run this job at a scheduled time every morning, it works some days but mostly it will fail. The error occurs when I get to this piece of code:
driver.find_element_by_class_name(submit_button_name).click()
wait = WebDriverWait(driver, 600)
wait.until(lambda driver: driver.current_url != login_url)
After it reaches the wait condition, it just waits until it runs out of time and the job fails. I checked the geckodriver logs and the redirect after submitting the login details never occurs, it just stays on the same page with the login details.
The code itself seems to work fine, its deploying it to aws-batch that is causing the issues
I have tried:
Is there something I could be missing when it comes to deploying selenium tests to ec2 instances? Do I need to provision particular resources to run these tests? What could cause this job to succeed sometimes and not others?
Upvotes: 0
Views: 555
Reputation: 168
Based on your description & the test is related to the Login section, while it's running fine locally and failed on AWS Batch, so i'm think of the high potential root cause that the resource (EC2 instance) having the right role, so it can be executed without being blocked by the page ( firewall)? Because sometimes the website firewall will detect if there's a bot browsing the page (which is from geckodriver, chromedriver, etc), so it will cache the page or block the container from being executed. So make sure you're having the right role for your EC2 instance (IAM role) & also trying to check if there's any thing that the firewall can prevent your container from being running properly ?
Upvotes: 0