Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running selenium (chromedriver) in a terminal window?

How can i run a python script using selenium (chromedriver) in an terminal window (without X forwarding).

The results/interactions with the website don't need to be shown. Par example filling a form scheduled by a cronjob.

like image 781
inselberg Avatar asked Dec 31 '25 21:12

inselberg


1 Answers

you can use PyVirtualDisplay with Xvfb

from pyvirtualdisplay import Display
from selenium import webdriver

display = Display(visible=0, size=(800, 600))
display.start()

# now Chrome will run in a virtual display. 
browser = webdriver.Chrome()
browser.get('http://www.google.com')
like image 57
r-m-n Avatar answered Jan 06 '26 12:01

r-m-n



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!