Question

I'm using Selenium2Library with RobotFramework for my framework. when I run this it always open a browser first and then start running test cases. Though I can minimize the browser by providing the keyword Minimize Browser Window . but problem is when some window popup it automatically maximize(foreground) the browser.

so I'm looking some thing which can hide the browser permanently, i mean browser will run in background(taking care of popups and all GUI design) and run all test cases.

is there any library or module for that. I heard phantomJs(http://phantomjs.org/ ) but i dont know whether it's a good choice or not (i heard this name first time).

Était-ce utile?

La solution

If you use RemoteWebDriver and selenium server locally, you will be able to run your tests in the background without opening of a browser.

Autres conseils

Use PhantomJs with Selenium Webdriver.

service_args = ['--load-images=false', '--ignore-ssl-errors=true', '--proxy-type=none']
phantomBinary = "\path\to\phantomjs.exe'
dcap = dict(webdriver.DesiredCapabilities.PHANTOMJS)
dcap["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36")
driver = webdriver.PhantomJS(executable_path=phantomBinary, desired_capabilities=dcap,                     service_args=service_args)

Ok! finally I've figured it out. I used Xvfb with PyVirtualDisplay . this is the code for same- visible=0 means browser will run in headless mode(in background)

from pyvirtualdisplay import Display
display = Display(visible=0, size=(1024, 700))
display.start()
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top