Advertisement
ridwan100

practice

Jan 17th, 2023
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1.  
  2.  
  3. import time
  4.  
  5. from selenium import webdriver
  6. from selenium.webdriver.common.by import By
  7. from selenium.webdriver.common.keys import Keys
  8. from selenium.webdriver.support import expected_conditions as EC
  9. from selenium.webdriver.support.wait import WebDriverWait
  10.  
  11. PATH = "C:\Program Files\chromedriver.exe"
  12. driver = webdriver.Chrome(PATH)
  13. driver.get("https://www.techwithtim.net")
  14. # print(driver.title)
  15. # search = driver.find_element(By.NAME,"s")
  16. # search.send_keys('test')
  17. # search.send_keys(Keys.RETURN)
  18. # try:
  19. #     main = WebDriverWait(driver, 10).until(
  20. #         EC.presence_of_element_located((By.ID, "main"))
  21. #     )
  22. #     articles = main.find_elements(By.TAG_NAME,"article")
  23. #     for article in articles:
  24. #         header = article.find_element(By.CLASS_NAME,"entry-summary")
  25. #         print(header.text)
  26. # finally:
  27. #     driver.quit()  
  28. link = driver.find_element(By.LINK_TEXT,"Python Programming")
  29. link.click()
  30. try:
  31.     element = WebDriverWait(driver, 10).until(
  32.         EC.presence_of_element_located((By.LINK_TEXT, "Beginner Python Tutorials"))
  33.      )
  34.     element.click()
  35.     element = WebDriverWait(driver, 10).until(
  36.         EC.presence_of_element_located((By.ID, "sow-button-19310003"))
  37.      )
  38.     element.click()
  39.     driver.back()
  40.     driver.back()
  41.     driver.back()
  42. except:
  43.         driver.quit()  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement