Selenium (software) code example
Example 1: selenium python
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
Example 2: what is selenium
- Selenium is a set of libraries that help us automate and interact
with the browsers.
Why Selenium?
- OPEN SOURCE -> FREE
- It supports different types of browsers
- It supports multiple different programming languages
- Huge community behind it so many answers to any problems/questions
- Could run on different OS systems such as: Mac, Windows, Linux etc.
Example 3: selenium 3
Selenium-3 differences
Understand the below things to know
how Selenium-3 is different from Selenium 2:
Minimum Java version required is above 1.8
GeckoDriver is required for the latest versions of Firefox Browser
Selenium 3 open the browsers by default
in maximized mode. Hence no need to
write driver.manage().window().maximize() command
Selenium 3 is more powerful and robust than Selenium 2
Stability fixes were done on Selenium
Grid of Selenium 3 to make it stable
Re-enabled log gathering for the
Selenium Standalone Server
In Selenium 3, mobile automation
support got removed i.e. AndroidDriver
and iPhoneDriver are removed from Selenium WebDriver library
We have to use other tools like
Appium for Mobile Automation
Appium tool extends the WebDriver
framework to create mobile tests)
Bug fixes were made for Selenium
WebDriver too in Selenium 3