Open terminal connection to your AWS Linux2 instance, execute the following commands in command line inteface terminal (CMD/Git Bash)
💡 see commands for a AWS EC2 Ubuntu instance at:
https://github.com/coddyca/seleniumaws
sudo yum update
sudo yum upgrade
curl https://intoli.com/install-google-chrome.sh | bash
google-chrome --version && which google-chrome
find the chromedriver version at https://chromedriver.storage.googleapis.com/index.html
98.0.4758.102
cd /tmp/
wget https://chromedriver.storage.googleapis.com/98.0.4758.102/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/bin/chromedriver
chromedriver --version
sudo amazon-linux-extras install java-openjdk11 -y
sudo yum update
sudo wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum upgrade
curl -LO 'https://rpmfind.net/linux/epel/7/x86_64/Packages/d/daemonize-1.7.7-1.el7.x86_64.rpm'
sudo rpm -Uvh ./daemonize-1.7.7-1.el7.x86_64.rpm
sudo yum install jenkins -y
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
cat /var/lib/jenkins/config.xml
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
sudo yum update
sudo yum install gcc openssl-devel bzip2-devel libffi-devel
sudo yum install python3
sudo yum install python3-pip
sudo pip3 install virtualenv
virtualenv --version
sudo yum install git
git --version
ssh-keygen
To find the public key:
cat /home/ec2-user/.ssh/id_rsa.pub
To find the private key:
cat /home/ec2-user/.ssh/id_rsa
- the sample code below is given for a Jankins project named: PythonSeleniumMoodle
- replace moodle_tests.py in python -m unittest discover --pattern=moodle_tests.py with your tests file name
💡 (important */master by default):
*/main
Setup a proper path, call virtualenv dir "venv", and virtualenv command installed in /usr/local/bin
PATH=${PATH}:/usr/local/bin
if [ ! -d "venv" ]; then
virtualenv venv
fi
. venv/bin/activate
pip3 install faker
pip3 install selenium
pip3 install pytest
cd /var/lib/jenkins/workspace/PythonSeleniumMoodle/
python3 -m unittest discover --pattern=moodle_tests.py
deactivate
python -m venv ./venv
cd venv/Scripts
call activate.bat
python.exe -m pip install --upgrade pip
pip install faker
pip install selenium
cd ../..
python -m unittest discover --pattern=moodle_tests.py
deactivate
REM comment lines start with REM (Remark) in Windows Batch File
REM create venv in current directory
python -m venv ./venv
REM go to Scripts directory and activate venv
cd venv/Scripts
call activate.bat
REM install additional libraries
python.exe -m pip install --upgrade pip
pip install faker
pip install selenium
REM go back
cd ../..
REM run the script
python -m unittest discover --pattern=moodle_tests.py
REM deactivate venv
deactivate
Navigate to the existing Python project (i.e. python_cctb) venv\Scripts directory, activate virtual environment, cd to project directory, run the scripts via moodle_tests.py file, deactivate virtual environment at the end
cd C:\Automation\Python\python_cctb\venv\Scripts
call activate.bat
cd C:\Automation\Python\python_cctb\practice\moodle
python -m unittest discover --pattern=moodle_tests.py
deactivate