I am trying to automate the login process to my web application using the Selenium-Python client library. The ultimate goal is to learn the Selenium Python client library. Therefore, I would be very grateful for the answers from those who fall into Selenium-Python.
I current have this code:
from selenium import webdriver from selenium.webdriver.common.keys import Keys browser = webdriver.Firefox()
This works well, but everything happens in the interface. I mean, it literally opens Firefox, keys in values, clicks on Submit, etc., as expected.
I'm just wondering if there is anything I can do to make this all happen in the background? Let's say I don't want to track what the script does. I just want it to run in the background. Is there any way to achieve this?
EDIT
We downloaded PyVirtualDisplay and installed it in my windows using the setup.py install command. Also installed EasyProcess module and Path.
Now I have a sample code like this
from pyvirtualdisplay import Display from selenium import webdriver display = Display(visible=0, size=(1024, 768)) display.start() browser = webdriver.Firefox() browser.get('http://www.google.com') print browser.title browser.close() display.stop()
I get the following errors while executing this code:
`Traceback (most recent call last): File "C:\Documents and Settings\user\Desktop\Sel.py", line 1, in <module> from pyvirtualdisplay import Display File "C:\Python27\lib\site-packages\pyvirtualdisplay\__init__.py", line 1, in <module> from display import Display File "C:\Python27\lib\site-packages\pyvirtualdisplay\display.py", line 2, in <module> from pyvirtualdisplay.xephyr import XephyrDisplay File "C:\Python27\lib\site-packages\pyvirtualdisplay\xephyr.py", line 8, in <module> EasyProcess([PROGRAM, '-help'], url=URL, ubuntu_package=PACKAGE).check_installed() File "C:\Python27\lib\site-packages\easyprocess\__init__.py", line 202, in check_installed raise EasyProcessCheckInstalledError(self) EasyProcessCheckInstalledError: cmd=['Xephyr', '-help'] OSError=[Error 2] The system cannot find the file specified Program install error! `