Skip to content

Instantly share code, notes, and snippets.

@jyotiska
Created August 23, 2016 20:18
Show Gist options
  • Select an option

  • Save jyotiska/effc0c1df3da402b8e827b054414a150 to your computer and use it in GitHub Desktop.

Select an option

Save jyotiska/effc0c1df3da402b8e827b054414a150 to your computer and use it in GitHub Desktop.
Selenium Blog Post Code
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.get("http://jyotiska.github.io/")
time.sleep(1)
blog_link = driver.find_element_by_name("Blog")
blog_link.click()
assert "blog" in driver.current_url
time.sleep(1)
driver.back()
time.sleep(1)
github_link = driver.find_element_by_name("Github")
github_link.click()
assert "jyotiska" in driver.current_url
time.sleep(1)
driver.back()
time.sleep(1)
all_projects = []
projects = driver.find_element_by_id("projects").find_elements_by_css_selector("li")
for item in projects:
all_projects.append(item.text)
assert len(all_projects) == 9
time.sleep(1)
all_talks = []
talks = driver.find_element_by_id("talks").find_elements_by_css_selector("li")
for item in talks:
all_talks.append(item.text)
assert len(all_talks) == 4
time.sleep(1)
driver.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment