0

I'm trying to click the button below but i'm getting a unable to find error.

<div class="sportsbook-outcome-cell__body selected" aria-label="Thomas Almeida " data-tracking="{&quot;section&quot;:&quot;GamesComponent&quot;,&quot;action&quot;:&quot;click&quot;,&quot;target&quot;:&quot;AddBet&quot;,&quot;sportName&quot;:34,&quot;leagueName&quot;:2162,&quot;subcategoryId&quot;:3,&quot;eventId&quot;:179567875}">
   <div class="sportsbook-outcome-body-wrapper">
      <div class="sportsbook-outcome-cell__label-line-container"><span class="sportsbook-outcome-cell__label">Thomas Almeida</span></div>
      <div class="sportsbook-outcome-cell__elements">
         <div class="sportsbook-outcome-cell__element"></div>
         <div class="sportsbook-outcome-cell__element"><span class="sportsbook-odds american default-color">-125</span></div>
      </div>
   </div>
</div>

I've tried by css select which is preferred because there are other names that I have to click on

browser.find_element_by_css_selector("div[aria-label='Thomas Almeida']").click()

I've also tried by full xpath, which only highlights the button it doesnt actually click it

 browser.find_element_by_xpath('/html/body/div[2]/div[2]/section/section[2]/section/div[3]/div/div[3]/div/div/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/div/div').click()

Any help is greatly appreciated.

Thanks,

2 Answers 2

1

There is a space between the ending quote and "Almeida":

browser.find_element_by_css_selector("div[aria-label='Thomas Almeida ']").click()
Sign up to request clarification or add additional context in comments.

Comments

0

I have a preference for using xpath. This is what I use at my current job and I feel like it's a good tool when you want to interact with a web element.

Solution: Find the element by xpath using Thomas's Name and the Game Component "AddBet"

browser.find_element(By.XPATH, "//div[contains(@aria-label, 'Thomas Almeida') and contains(@data-tracking, 'AddBet')]").click()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.