Selenium testing without browser Selenium testing without browser selenium selenium

Selenium testing without browser


Chrome now has a headless mode:

op = webdriver.ChromeOptions()op.add_argument('headless')driver = webdriver.Chrome(options=op)


You can run Selenium headless, take a look at this question/answer: Is it possible to hide the browser in Selenium RC?

Especially for performance load tests, you should have a look at Apache JMeter.


To set up on Centos (do all installation as root)

Install pip Download https://bootstrap.pypa.io/get-pip.py

python get-pip.py

Installing seleniumIf you have pip on your system, you can simply install or upgrade the Python bindings: pip install -U selenium

Alternately, you can download the source distribution from PyPI (e.g. selenium-2.53.1.tar.gz), unarchive it, and run:

python setup.py install

install the program: pyvirtualdisplay

pip install pyvirtualdisplayyum install Xvfb libXfont Xorg

Then modify your script to add the bold lines within ** and **

**from pyvirtualdisplay import Display**from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.support.ui import Selectfrom selenium.common.exceptions import NoSuchElementExceptionfrom selenium.common.exceptions import NoAlertPresentExceptionimport unittest, time, reclass SeleniumDemo(unittest.TestCase):    def setUp(self):        **self.display = Display(visible=0, size=(800, 600))        self.display.start()**        self.driver = webdriver.Firefox()        self.driver.implicitly_wait(30)        self.base_url = "http://www.soastastore.com/"        self.verificationErrors = []        self.accept_next_alert = True    def tearDown(self):`enter code here`        self.driver.quit()        ***self.display.stop()***        self.assertEqual([], self.verificationErrors)