Skip to content

Instantly share code, notes, and snippets.

@Anas-jaf
Created December 28, 2021 11:02
Show Gist options
  • Save Anas-jaf/dc85d223171dc25e97804d31fbf28bb0 to your computer and use it in GitHub Desktop.
Save Anas-jaf/dc85d223171dc25e97804d31fbf28bb0 to your computer and use it in GitHub Desktop.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("https://github.com/search?q=python%2Fcpython&type=")
elem = driver.find_element_by_name("q")
elem.click()
elem.send_keys("python/cpython")
elem.send_keys(Keys.RETURN)
# time.sleep(2)
# elem1= driver.find_element_by_xpath("//*[contains(text(), 'cpython')]")
driver.find_element_by_link_text("python/cpython").click()
elems = driver.find_elements_by_xpath("//a[@href]")
for elem in elems:
if elem.get_attribute("href") == "https://travis-ci.com/python/cpython":
print ("Found!")
elif elem.get_attribute("href") == "https://github.com/python/cpython/actions":
print ("Found!")
elif elem.get_attribute("href") == "https://dev.azure.com/python/cpython/_build/results?buildId=93713&view=results":
print ("Found!")
elif elem.get_attribute("href") == "https://discuss.python.org/":
print ("Found!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment