- Newest
- Most votes
- Most comments
It seems you're encountering a common issue when trying to run Selenium with Chrome WebDriver on an EC2 Linux instance. There are a few things you can try to resolve this:
-
Ensure you have all necessary dependencies installed. On a Linux EC2 instance, you might need to install additional libraries for Chrome to run properly. Try installing these packages:
sudo yum install -y libX11 libXcomposite libXcursor libXdamage libXext libXi libXtst cups-libs libXScrnSaver libXrandr alsa-lib pango atk at-spi2-atk gtk3
-
Use the '--no-sandbox' option when initializing Chrome. This is often necessary when running Chrome as a non-root user on Linux:
chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-dev-shm-usage')
-
Make sure you're using a compatible version of ChromeDriver for your installed Chrome version. You can check the Chrome version with:
google-chrome --version
Then download the matching ChromeDriver version.
-
If you're still having issues, consider using AWS Device Farm for desktop browser testing instead of running Selenium directly on EC2. Device Farm provides a managed Selenium Grid that can be easier to set up and maintain. You would need to modify your RemoteWebDriver initialization to use the Device Farm WebDriver endpoint.
-
Another alternative is to use AWS CloudWatch Synthetics, which supports writing canary scripts using the Selenium test framework. This could potentially simplify your setup as it handles many of the environment configuration details for you.
If none of these solutions work, you might need to investigate further by checking EC2 instance logs or running Chrome with verbose logging enabled to get more detailed error information.
Remember to grant only the necessary permissions to your EC2 instance and follow AWS security best practices when configuring your setup.
Sources
Library functions available for Python canary scripts using Selenium - Amazon CloudWatch
Migrating to Device Farm desktop browser testing from Selenium Grid - Device Farm desktop browser testing
Runtime versions using Python and Selenium Webdriver - Amazon CloudWatch
Migrating to Device Farm desktop browser testing from local Selenium WebDrivers - Device Farm desktop browser testing
Relevant content
- asked a year ago
- asked a year ago
- AWS OFFICIALUpdated 2 months ago