Advertisement
alphauser420

dropdown

Mar 12th, 2024
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.by import By
  3. from selenium.webdriver.support.ui import Select
  4. import time
  5.  
  6. driver = webdriver.Chrome()
  7. driver.maximize_window()
  8. driver.get("https://omayo.blogspot.com/")
  9.  
  10. # For dropdown
  11. dropdown = driver.find_element(By.ID, "drop1")
  12.  
  13. # Creating Select object
  14. select = Select(dropdown)
  15.  
  16. # Selecting an option by visible text
  17. select.select_by_index(2) # Change "Option 2" to the desired option text
  18. print("Changed value to index 2")
  19. time.sleep(20) # Giving a brief pause to see the changes (not required, but good for demonstration)
  20. driver.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement