I have a python test and I want to run it without opening the firefox
I want to hide it so how can I do this ?
any help ?
I have a python test and I want to run it without opening the firefox
I want to hide it so how can I do this ?
any help ?
# pip install selenium
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_argument('--headless')
driver = webdriver.Firefox(options=options)
driver.get('https://www.google.com/doodles')
print('Title: "{}"'.format(driver.title))
driver.quit()
You can try to set negative window position to hide browser:
driver.set_window_position(-3000, 0) # driver.set_window_position(0, 0) to get it back
or try PhantomJS
headless browser, that allow to run UI
tests without displaying browser window
Have a look at this answer: https://stackoverflow.com/a/6300672/2929488
#!/usr/bin/env python
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
# now Firefox will run in a virtual display.
# you will not see the browser.
browser = webdriver.Firefox()
browser.get('http://www.google.com')
print browser.title
browser.quit()
display.stop()