Issue
Obligatory: New to Selenium webdriver
and Python.
I am attempting to scrape cricket scores from this page https://www.playhq.com/cricket-australia/org/saca-premier-cricket/senior-men-summer-202324/west-end-mens-2nd-grade/game-centre/7cb22178
It has all gone swimmingly for the data on-screen in the initial view.
When I try to click the Glenelg 1st Innings button to change the view, I get:
Message: element click intercepted: Element is not clickable at point (316, -283)
I have tried using a variety of xpaths
. This appears to be the best option
//*[@data-testid='period-tab-container']/button[2]
I am able to resolve the correct text from these xpaths
.
I don't think it is related to implicit wait times. I'm using driver.implicitly_wait(5).
Everything else is present on this page.
Of course, I could be incorrect.
These score pages are dynamically created. Are they masking the button functionality somehow?
I have tried using the brute force path //button[text()='Glenelg 1st Innings']
It is clearly finding the element. I can read the text.
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
targetURL = "https://www.playhq.com/cricket-australia/org/saca-premier-cricket/senior-men-summer-202324/west-end-mens-2nd-grade/game-centre/7cb22178"
driver.get(targetURL)
title = driver.title
driver.implicitly_wait(5)
# lots of other code in here
# is able to correctly resole page elements
# removed for brevity
other_innings_button = driver.find_element(by=By.XPATH,
value="//*[@data-testid='period-tab-container']/button[2]")
print(other_innings_button.text)
other_innings_button.click()
Solution
Instead of :
other_innings_button.click()
you must use:
from selenium.webdriver.common.keys import Keys
other_innings_button.send_keys(Keys.ENTER)
Answered By - Mattie Geren
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.