Selenium is an open-source project, wide set of tools for web browser automation.
It is used for automated testing, and validate web applications, with a variety of web browsers using a large set of programming languages including Java, C#, Python.
- What is Selenium?
- How to install Java JDK on AWS Ec2 Amazon Linux 2?
- How to Install Apache Maven on Amazon Linux 2?
- How to Install Selenium Chrome Driver on Amazon Linux 2?
What is Selenium?
Selenium is a wide project, now we concentrate on the installation of WebDriver.
It implements a system for controlling browsers by directly communicating with them.
How to install Java JDK on AWS Ec2 Amazon Linux 2
Amazon AWS is the worldwide most reliable, secure cloud platform offering hundreds ton of services located in world data centers.
If you want to have full control like a hardware home server you can use AWS EC2 admin management for start, restart, setup configuration
When you create a EC2 instance you download your private keys (pem file) for connecting in ssh to your instance.
After connecting, first time you need to update the system packages:
sudo yum update
To install java 11 on Amazon Linux 2 using below command
sudo amazon-linux-extras install java-openjdk11
After installation check the installed OpenJDK version using command line below:
java --version
Use below command to switch java version
sudo alternatives --config java
How to Install Apache Maven on Amazon Linux 2
Download the latest Apache Maven version from Apache Maven official download page.
Navigate to /tmp directory where you want download Apache Maven
cd /tmp
Download the Apache Maven version using wget
sudo wget <https://www-eu.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz>
once downloaded extract the apache maven setup in /opt directory
sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt
Create a symlink for Apache maven directory to update the maven versions
sudo ln -s /opt/apache-maven-3.8.1 /opt/maven
Setup Apache Maven Environment Variables
To setup apache maven environment variables in Amazon Linux 2, create a file named maven.sh in /etc/profile.d/ directory
sudo nano /etc/profile.d/maven.sh
Paste the below lines
export JAVA_HOME=/usr/lib/jvm/jre-11-openjdk
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
Give the executable permission using chmod
sudo chmod +x /etc/profile.d/maven.sh
Load the Environment Variables using source command
source /etc/profile.d/maven.sh
Verify the installed maven version using the command line
mvn -version
Installing ChromeDriver
You will need to install ChromeDriver which allows you programmatic access to google chrome via the Webdriver API protocol.
- Firstafall get ChromeDriver using wget
- Unzip ChromeDriver
- Move ChromeDriver to the bin applications folder.
wget <https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip>
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/bin/chromedriverchromedriver --version
Installing Google Chrome
For the ChromeDriver to work we also need to install Google Chrome. After you run the first curl command in the code block below, it might take a little while to download and install the necessary files.
curl <https://intoli.com/install-google-chrome.sh> | bash
sudo mv /usr/bin/google-chrome-stable /usr/bin/google-chrome
google-chrome --version && which google-chrome
Now you should have both Google Chrome and the ChromeDriver installed.