A module that sits ontop of Selenium to streamline scraping and automation workflows.
Install with:
pip install seleniumuser
Currently supports using firefox or chrome.
You will need to have the appropriate web driver executable for the browser and your system in either the system PATH or a location passed to the User class constructor.
They can be found here:
Firefox
Chrome
from seleniumuser import User user = User(browser_type="firefox") user.get('https://somewebsite.com') user.send_keys('//input[@id="first-name"]', 'Bill') user.fill_next(['Billson', 'bill@bill.com', '5345548486']) user.click('//button[@id="submit"]') try: user.wait_until(lambda: 'Submission Received' in user.text('//p[@id="confirmation-message"]')) print('Submission success.') except TimeoutError: print('Submission failed.') user.close_browser()
The User class supports being used with a context manager if you'd rather not worry about closing the browser before exiting the script:
from seleniumUser import User with User(browser_type="firefox") as user: user.get('https://somewebsite.com') user.send_keys('//input[@id="first-name"]', 'Bill') user.fill_next(['Billson', 'bill@bill.com', '5345548486']) user.click('//button[@id="submit"]') try: user.wait_until(lambda: 'Submission Received' in user.text('//p[@id="confirmation-message"]')) print('Submission success.') except TimeoutError: print('Submission failed.')