A. What Do You Need?
B. Getting Started With Source
- Python 3
- Selenium WebDriver (Hint: pip install selenium)
Create a new *.py file and open it in your favorite text editor.
Import the Selenium Webdriver Module
from selenium import webdriver
Create an instance of the FireFox webdriver
browser = webdriver.Firefox()
Great! Now you can have the "browser" control your firefox web browser how-so-ever you want. Examples:
Ask the webdriver to navigate to a new webpage:
Maximize the firefox window:
To click a button on the web page:
btn = browser.find_element_by_xpath('ELEMENTS_XPATH')
*Replace the ELEMENTS_XPATH by the xPath of the element (Hint: Open Chrome, Inspect Elements -> Find the HTML of the button, the right-click on it, the select "copy xpath")
You can select elements by their css paths. There are a lot of ways! Google!
To close the browser:
That's all for now, because I gotta go study for my Shell Programming exam.
Cya and more tutorials soon!
Do not let your difficulties fill you with anxiety, after all it is only in the darkest nights that stars shine more brightly. - Ali(a.s)
Developer( PHP, Python, C++, HTML+CSS, JS I am available for Hire. Message Me for details.