Issue
The following site below recently updated their UI and my existing code no longer works for reasons I cannot figure out. My function (proline_go_to_match1) used to select and click on the game using the PARTIAL_LINK_TEXT where I passed the team name. The team name exists in the link however I am getting the error message pasted below. I have included my code snippet and would greatly appreciate if anyone knows why this happening and how to fix it.
Thank you very much!
Website: https://prolineplus.olg.ca/en-ca/event-path/?p23795-NBA
Error message:
"Message: element click intercepted: Element <a href="/en-ca/event/?e109531-NBA-Basketball-USA-Toronto-Raptors-Atlanta-Hawks">...</a> is not clickable at point (415, 697). Other element would receive the click: <div class="cc-content">...</div>"
Code:
def proline_go_to_match1(driver, team):
try:
match = WebDriverWait(driver, 15).until(
EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, team))
)
match.click()
except Exception as e:
print(e)
proline_driver = webdriver.Chrome()
proline_driver.get('https://prolineplus.olg.ca/en-ca/event-path/?p23795-NBA')
capitalized_team = "TORONTO RAPTORS"
proline_go_to_match1(proline_driver,capitalized_team)
Here I have circled the link I would like click passing "TORONTO RAPTORS"
Solution
Seems you are close enough.
Instead of presence_of_element_located() you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following locator strategy:
Using PARTIAL_LINK_TEXT:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, f"{capitalized_team}"))).click()
Using XPATH:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(., '" +capitalized_team+ "')]"))).click()
Update
It's the cookie banner content which blocks your click
Solution
You need to accept the cookies:
driver.get("https://prolineplus.olg.ca/en-ca/event-path/?p23795-NBA")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.cc-btn.cc-dismiss"))).click()
capitalized_team = "TORONTO RAPTORS"
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, f"{capitalized_team}"))).click()
Browser Snapshot:
Answered By - undetected Selenium
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.