http://selenium-python.readthedocs.io/locating-elements.html
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
class PythonOrgSearch(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
def test_search_in_python_org(self):
driver = self.driver
driver.get("https://qa.college.harvard.edu/financial-aid/net-price-calculator")
self.assertIn("Calculator", driver.title)
elem = driver.find_element_by_class_name("modal-close")
elem.click()
elem = driver.find_element_by_class_name("output")
self.assertEqual(str(elem.text), "$0")
driver.get("https://qa.college.harvard.edu/about")
self.assertIn("About | Harvard College", driver.title)
elem=driver.find_element_by_class_name("field-name-body")
self.assertIn("Undergraduate Experience", str(elem.text))
driver.get("https://qa.college.harvard.edu/admissions")
self.assertIn("Admissions", driver.title)
elem=driver.find_element_by_class_name("field-name-field-landing-page-center-desc")
self.assertIn("receive some form of financial aid", str(elem.text))
driver.get("https://qa.college.harvard.edu/academics")
self.assertIn("Academics", driver.title)
elem=driver.find_element_by_class_name("field-name-body")
self.assertIn("Learn in one of", str(elem.text))
driver.get("https://qa.college.harvard.edu/student-residentiallife")
self.assertIn("Student & Residential", driver.title)
elem=driver.find_element_by_class_name("field-name-body")
self.assertIn("A Community Designed to Support You", str(elem.text))
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()