Purpose: To build a framework around the Selenium WebDriver to simplify the basic capabilities that are most frequently used (in my experience anyway).
- Install Python version 3
- Install the selenium bindings for Python:
pip install selenium
- Note: If you wish to run the test_framework.py script, you also need to install pytest.
- Install the selenium_framework.py file into a location searchable by Python
- i.e. site-packages or the folder containing your project scripts
import selenium_framework as sf
CONFIG = {
'browser': 'Chrome',
'headless': True,
'browser_size': (800, 600),
'browser_position': (0, 0),
'test_page': f'https://duckduckgo.com/'
}
driver = sf.Driver()
driver.open(CONFIG)
driver.goto(CONFIG['test_page'])
element = driver.find('name=q')
element.send_keys('SeleniumHQ')
element.submit()
assert driver.browser.title == 'SeleniumHQ at DuckDuckGo'
driver.close()
Selenium Website
Selenium Repo
Firefox Gecko Driver Documentation
Firefox Gecko Driver repo