The content of the python script selenium_xvfb.py that uses the fake X server can be seen below. You most likely want to use a server to perform automated testing, therefore you need a fake X server: # apt-get install xvfb selenium.py For Systems without an X Server To run the script, use the following: $ python. # The element IDs will likely be different for your application,īrowser.find_element_by_id("logout_link").click()īrowser.find_element_by_id("dialog_button_ok").click() Password = browser.find_element_by_name("j_password")īrowser.find_element_by_id("submit").click() User = browser.find_element_by_name("j_username") # The element names will likely be different for your application, # Set a user agent string to help parse webserver logs easily # Initial release, script uses one hardcoded URL The script will open Firefox, therefore you need to have an X server running. The content of the python script selenium.py can be seen below. ![]() # chmod 755 /usr/local/bin/geckodriver Python Scripts For Systems with an X Server # chown root:root /usr/local/bin/geckodriver We will need the latest geckodriver: # wget # tar xf geckodriver-v0.18.0-linu圆4.tar.gz -C /usr/local/bin/ ![]() Or go for Iceweasel instead: # apt-get install iceweasel Install Selenium and Firefox: # apt-get install python-pip Scripts should work on any modern Debian/Ubuntu system. The first script is suitable for a system that has an X server running, while the second one utilises a Virtual Framebuffer “fake” X server. I was working with Selenium (well, Python) scripts for several years now, this article aims to provide two basic Python scripts that can be used to log in and then log out from a website. Using Selenium for automated website testing.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |