0

I am trying to click into the Over/Under Section on this Website: https://www.oddsportal.com/soccer/chile/primera-division/curico-unido-o-higgins-CtsLggl6/

The HTML is:

            <li class=" active" style="display: block;"><span class="topleft_corner"></span><span class="topright_corner"></span><strong><span>Over/Under</span></strong></li>

I have tried the following:

overunder=browser.find_element_by_link_text('Over/Under')

overunder=wait(browser, 5).until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(), 'Over/Under']")))


overunder=browser.findElement(By.xpath("//span[contains(text(), 'Over/Under']"))

All of these followed by overunder.click()

However all result in a NosuchElementException.

How can I click this item? I am trying to access and scrape the Over/Under Websites behind this section.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • There is no such element with the text "Over/Under" when I load the page. This element is present, though. `O/U`. – Joeri Jan 16 '21 at 00:41

3 Answers3

0

When I checked the page_source of the link you provided using selenium, this is what I get for area you're looking for:

<li class="" style="display: block;"><a onmousedown="uid(5)._onClick();return false;" title="Over/Under" href=""><span>O/U</span></a></li>

I used

browser.find_element_by_css_selector("a[title='Over/Under']").click()

which worked for me.

goalie1998
  • 1,427
  • 1
  • 9
  • 16
0

I copied the full xpath and this worked for me:

browser.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[6]/div[1]/div/div[1]/div[2]/div[1]/div[5]/div[1]/ul/li[5]/a").click()
Insula
  • 999
  • 4
  • 10
0

Instead of the element with text Over/Under, I see the element with text O/U

OverUnder

To click on the element with text as save you can use either of the following Locator Strategies:

  • Using css_selector:

    driver.find_element(By.CSS_SELECTOR, "a[title='Over/Under'] > span").click()
    
  • Using xpath:

    driver.find_element(By.XPATH, "//a[@title='Over/Under']/span[text()='O/U']").click()
    

Ideally, to click on the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[title='Over/Under'] > span"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@title='Over/Under']/span[text()='O/U']"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
  • Browser Snapshot:

Over_Under

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352