The simplest way to run python headless test with Chrome on Ubuntu

Опубликовано: 14 Октябрь 2024
на канале: Softhints - Python, Linux, Pandas
10,851
79

Python headless test with Chrome on Ubuntu

https://blog.softhints.com/python-hea...

tech environment:

latest python 3.7
Chromedriver 2.41
selenium (3.14.0)
Ubuntu 18.04
Chrome 69
Katalon studio

step 1 python and selenium module

pip install -U selenium

step 2 Chrome and chromedriver

unzip chromedriver_linux64.zip

step 3 Run headless tests with Chrome


from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')

driver = webdriver.Chrome('/home/user/Downloads/chromedriver_linux64/chromedriver', chrome_options=chrome_options, service_args=['--verbose', '--log-path=/tmp/logs/chromedriver.log'])


driver.get('https://google.org')
print(driver.title)


step 4 Customize the headless script


Please answer what would you do if you have: several free week and a home computer?

---------------------------------------------------------------------------------------------------------------------------------------------------------------
Code store

https://bitbucket.org/softhints/

Socials

Facebook:   / 435421910242028  
Facebook:   / softhints  
Twitter:   / softwarehints  
Discord:   / discord  


If you really find this channel useful and enjoy the content, you're welcome to support me and this channel with a small donation via PayPal.

PayPal donation https://www.paypal.me/fantasyan