Selenium is a portable framework for testing web applications. Selenium provides a playback tool for authoring functional tests without the need to learn a test scripting language (Selenium IDE). It also provides a test domain-specific language (Selenese) to write tests in a number of popular programming languages, including C#, Groovy, Java, Perl, PHP, Python, Ruby and Scala. The tests can then run against most modern web browsers. Selenium runs on Windows, Linux, and macOS. It is open-source software released under the Apache License 2.0.
This program provides the HTTP API described by the WebDriver protocol to communicate with Gecko browsers, such as Firefox. It translates calls into the Marionette remote protocol by acting as a proxy between the local- and remote ends.
You need to install:
If you have arch linux just run:
!yes | sudo pacman -S python-selenium geckodriver
If you have ubuntu linux run:
%%bash
wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
sudo sh -c 'tar -x geckodriver -zf geckodriver-v0.26.0-linux64.tar.gz-O > /usr/bin/geckodriver'
sudo chmod +x /usr/bin/geckodriver
rm geckodriver-v0.26.0-linux64.tar.gz
If you have windows install linux :)
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
# Creating instance of Firefox WebDriver
# The webdriver controls a browser by sending commands to a remote server.
driver = webdriver.Firefox()
# Navigate to a page given by the URL.
# WebDriver will wait until the page has fully loaded
driver.get("https://duckduckgo.com")
# Get search bar
search_bar = driver.find_element_by_id("search_form_input_homepage")
# Type Hello World!
search_bar.send_keys("Hello World!")
# "Press" return
search_bar.send_keys(Keys.RETURN)
driver.close()
def get_grade(username, password):
driver = webdriver.Firefox()
driver.get("http://pithia.teithe.gr/unistudent/")
driver.find_element_by_id("userName").send_keys(username)
driver.find_element_by_id("pwd").send_keys(password)
driver.find_element_by_id("submit1").click()
driver.find_element_by_id("mnu3").click()
page_source = driver.page_source
driver.close()
soup = BeautifulSoup(page_source, 'html.parser')
return soup.find("tbody").find_all("tr")[len(soup.find("tbody").find_all("tr")[102])-10].find("span").getText()
#print(get_grade("username", "password"))