One of the real advantages of Selenium is that there are binding for all of the most popular languages, Python being one of them! The Python bindings are among the most intuitively written and the documentation surrounding the binding is among the most complete. While all of the Selenium bindings are similar, there are small differences that can make getting your first test running in a new language frustrating. To alleviate these issues I have provided a few of the most commonly used commands using the Python binding.
Most Commonly Used Commands :
Instantiating the Remote WebDriver
- driver = webdriver.Remote( command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=DesiredCapabilities)
Finding an Element:
- driver.find_element_by_link_text(“link text”)
- driver.find_element_by_partial_link_text(“partial link text”)
Interacting with Elements
Ending the WebDriver Session:
To run a Python Selenium test you can simply use the command "python my_file.py" in the terminal, provided the libraries are imported correctly. To run tests without the trouble of an in-house grid Sauce Labs is an excellent alternative.
Why Sauce Labs?
- Cloud based Selenium grid with over 800+ browser and OS combinations
- Test behind your firewall with Sauce Connect, a secure tunneling tool
- Eliminate infrastructure maintenance
Get our Selenium Bootcamp guide and get started with testing today!