Reputation: 1190
i try to click on the "Top Crossing" button on this site: https://sensortower.com/ios/rankings/top/iphone/us/games?date=2021-07-12 (the button seems to be available only when the width is set to a lower value - so i tried to change the windows size with the following statement which seems to work fine:
driver.set_window_size(600,1000)
this is the full code with which i try to press the button
options = Options()
options.add_argument("--window-size=1920x800")
options.add_argument('--no-sandbox')
options.add_argument('--disable-gpu')
options.add_experimental_option ('excludeSwitches', ['enable-logging'])
path = os.path.abspath (os.path.dirname (sys.argv[0]))
if sys.platform == "win32": cd = '/chromedriver.exe'
elif sys.platform == "linux": cd = '/chromedriver'
elif sys.platform == "darwin": cd = '/chromedriver'
driver = webdriver.Chrome (path + cd, options=options)
link = "https://sensortower.com/ios/rankings/top/iphone/us/games?date=2021-07-12"
driver.get(link)
driver.set_window_size(600,1000)
wait = WebDriverWait(driver, 10)
tmpElem = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[@id='onetrust-accept-btn-handler']")))
tmpElem.click()
tmpElem = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Top Grossing']")))
tmpElem.click()
But with that i only get the following error message:
File "C:\Users\Polzi\Documents\DEV\Upwork\MT\scrapeSensorTower.py", line 78, in <module>
tmpElem.click()
File "C:\Users\Polzi\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\Polzi\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\Users\Polzi\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\Polzi\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <span class="universal-button-text" data-bind="text: $data.name">...</span> is not clickable at point (243, 434). Other element would receive the click: <div class="shadowed-st content rankings-table-container flex-span-12">...</div>
(Session info: chrome=91.0.4472.124)
Any ideas how i am able to press this button?
Upvotes: 0
Views: 1745
Reputation: 33353
As I see the element matching the //span[text()='Top Grossing']
locator is not really clickable. It is not a kind of button etc rather that some element containing that text. So when clicking on it some other element, it's parent element is actually receiving the click.
I'm not sure this is the element you need to click.
Upvotes: 0
Reputation: 111
Try executing the .click()
JavaScript method on the element:
Replace:
tmpElem.click()
With:
driver.execute_script('arguments[0].click();', tmpElem)
Upvotes: 1