Can’t find element selenium even though it certainly exists

I have some trouble finding a element here Link

I want to scrape the names of the matches using:

WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[7]/div[1]/div/div/div[4]/div/div/main/div[2]/div/div/div/div//div/div/div/article/main/a/span')))

(I don’t like using the XPath, but otherwise I’d also get the bets that weren’t just full time result bets)

But when I run this it returns an empty list. I have tried figuring out wether the match names are within an iframe or something but I can’t figure it out. Does someone know how I can scrape these elements?

N.B. I have checked multiple times whether the XPath is actually in the HTML and it is.

Answer

so the code you are using is to wait the page to load until the xpath is found. I wrote the code below and it works. It just prints dates too, you need to adjust. However I just run it so I am confident it works. Ensure you load all the dependencies in the top. It works with class and not xpath.

driver.get("https://sports.williamhill.com/betting/en-gb/football/competitions/OB_TY295/English-Premier-League/matches/OB_MGMB/Match-Betting")
WebDriverWait(driver, 10).until(
    lambda x: x.find_element_by_class_name('sp-o-market__title').is_displayed())
out = driver.find_elements_by_class_name('sp-o-market__title')
for item in out:
    item = item.get_attribute('innerHTML')
    item = item.split('<span>')[1]
    item = item.split("</span>")[0]
    print(item)

Produces:

Arsenal v Norwich
Brentford v Brighton