'Change all option tags to the same value
I am trying get all the rounds to be the same and the best i can do is change the first one. The current code has all the player scorecards open now i just need to be able to select the same round for all of them.
ignore all the imports i was trying a few things, i am extremely new to this
Thank you!
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from bs4 import BeautifulSoup
import requests
PATH = "C:\Program Files (x86)\Chrome\chromedriver_win32\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://www.espn.com/golf/leaderboard?tournamentId=401353233")
xpath_number = 1
while True:
try:
element = driver.find_element_by_xpath(f'//*[@id="fittPageContainer"]/div[3]/div/div/section[3]/div/div/div/div[2]/div[3]/div/div/div/div[2]/table/tbody/tr[{xpath_number}]/td[1]')
xpath_number += 1
action = ActionChains(driver)
action.click(element)
action.perform()
except NoSuchElementException:
break
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
