English 中文(简体)
我保留了该要素的案文。
原标题:I keep getting a timeout error for an element even though it prints out the text of that element

我是新 to的,我的主要目标是废除我为我所玩的每一条游戏而获得的录像游戏。

driver = webdriver.Chrome()
    url = "https://destinytracker.com/destiny-2/profile/psn/4611686018440125811/matches?mode=crucible"
    driver.get(url)
    wait = WebDriverWait(driver, 30)
    ignored_exceptions=(NoSuchElementException,StaleElementReferenceException)
    crucible_content = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.trn-gamereport-list.trn-gamereport-list--compact")))
    game_reports = crucible_content.find_elements(By.CLASS_NAME, "trn-gamereport-list__group")
    for game_report in game_reports:
        group_entry = wait.until(EC.presence_of_element_located((By.CLASS_NAME, "trn-gamereport-list__group-entries")))
        win_match = group_entry.find_elements(By.CLASS_NAME,"trn-match-row--outcome-win")
        driver.execute_script("arguments[0].scrollIntoView();", win_match[0])
        lose_match = group_entry.find_elements(By.CLASS_NAME, "trn-match-row--outcome-loss")
        for win_element in win_match:
            
            #try:
                #sleep(10)
                #driver.execute_script("arguments[0].scrollIntoView();", win_element)
                
            win_left = wait.until(EC.presence_of_element_located((By.CLASS_NAME, "trn-match-row__section--left")))
            driver.execute_script("arguments[0].click();", win_left)
            print("reached here")
            date_time = wait.until(EC.presence_of_element_located((By.XPATH, "//div[@class= info ]")))
            date_time = date_time.text
            date_time = date_time.split(",")
            date_time = date_time[0]
            match_roster = wait.until(EC.presence_of_element_located((By.CLASS_NAME,"match-rosters")))
            team_alpha = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "div.match-roster.alpha")))
            team_bravo = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "div.match-roster.bravo")))
            bravo_match_roster_entries = team_bravo.find_element(By.CLASS_NAME, "roster-entries")
            alpha_match_roster_entries = team_alpha.find_element(By.CLASS_NAME,"roster-entries")
            name = wait.until(EC.presence_of_element_located((By.CLASS_NAME, "router-link-active")))
            entry_bravo = bravo_match_roster_entries.find_elements(By.CLASS_NAME,"entry")
            entry_alpha = alpha_match_roster_entries.find_elements(By.CLASS_NAME,"entry")
            print(date_time)

I want to loop over each win I have and collect the stats from that game(along with the time.) I get this result:

reached here
7/12/2023
reached here
Traceback (most recent call last):
  File "/Users/victoruduma/Documents/python web scraping part 2 .py", line 121, in <module>
    crucible_dataset()
  File "/Users/victoruduma/Documents/python web scraping part 2 .py", line 55, in crucible_dataset
    date_time = wait.until(EC.presence_of_element_located((By.XPATH, "//div[@class= info ]")))
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/selenium/webdriver/support/wait.py", line 95, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

问题一是,即使我发现这一错误,它仍然照旧。 在过去的一周里,我一直 st着这个问题,甚至在基督教女权运动会的帮助下。 任何帮助都会得到真正赞赏。

问题回答

您在<代码>win_match和click上登上<代码>win_left时,请上close。 滚动窗口,在<代码>win_match的下坡前点击。

wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.close"))).click()

在这方面:

from time import sleep
from selenium.common import TimeoutException
from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait


driver = Chrome()
url = "https://destinytracker.com/destiny-2/profile/psn/4611686018440125811/matches?mode=crucible"
driver.get(url)
wait = WebDriverWait(driver, 30)

crucible_content = wait.until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "div.trn-gamereport-list.trn-gamereport-list--compact")))
game_reports = crucible_content.find_elements(By.CLASS_NAME, "trn-gamereport-list__group")

for game_report in game_reports:
    group_entry = wait.until(EC.presence_of_element_located((By.CLASS_NAME, "trn-gamereport-list__group-entries")))
    win_match = group_entry.find_elements(By.CSS_SELECTOR, "div.trn-match-row--outcome-win")
    driver.execute_script("arguments[0].scrollIntoView();", win_match[0])
    lose_match = group_entry.find_elements(By.CSS_SELECTOR, "div.trn-match-row--outcome-loss")
    for win_element in win_match:

        try:
            win_left = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "div.trn-match-row__section--left")))
            driver.execute_script("arguments[0].click();", win_left)
            print("reached here")
            date_time = wait.until(EC.presence_of_element_located((By.XPATH, "//div[@class= info ]")))
            date_time = date_time.text.split(",")[0]
            match_roster = wait.until(EC.presence_of_element_located((By.CLASS_NAME, "match-rosters")))
            team_alpha = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "div.match-roster.alpha")))
            team_bravo = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "div.match-roster.bravo")))
            bravo_match_roster_entries = team_bravo.find_element(By.CLASS_NAME, "roster-entries")
            alpha_match_roster_entries = team_alpha.find_element(By.CLASS_NAME, "roster-entries")
            name = wait.until(EC.presence_of_element_located((By.CLASS_NAME, "router-link-active")))
            entry_bravo = bravo_match_roster_entries.find_elements(By.CLASS_NAME, "entry")
            entry_alpha = alpha_match_roster_entries.find_elements(By.CLASS_NAME, "entry")
            print(date_time)
            wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.close"))).click()
            sleep(1)
        except TimeoutException:
            pass

产出:

reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023
reached here
7/13/2023




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签