Python - Unable to click button in Selenium under tooltip, webpage throws request error

Refresh

April 2019

Views

37 time

1

This is the element I am trying to click (the info button). It's located on pokemongomap.info, and you can see it in chrome devtools under any pokestop or gym.

<a href="#" target="_self" class="tooltip tooltipstered" id="infoboxmoreinfobtnbind" style="display: inline;">
    <div id="infoboxmoreinfohit"></div>
    <div id="infoboxmoreinfobtn" class="infoboxbtn">
        <i class="fa fa-info-circle" aria-hidden="true" style="color: rgb(57, 135, 140);">

        </i>
    </div>
</a>

I am unable to click it using ActionChains, element.click(), or anything else. If I try to click it using either of those methods, I get a request error from the website. Can anyone help me? Here is some of the code I have tried.

wait = WebDriverWait(driver, 10)
actions = Actions(driver)
element = wait.until(EC.element_to_be_clickable((By.ID, 'infoboxmoreinfobtnbind')))
#element = wait.until(EC.element_to_be_clickable((By.XPATH, '//i[@class="fa fa-info-circle"]'))) also throws error when clicked

#actions.move_to_element(element).click(element).perform() doesn't work either.

action = actions.move_to_element(element)
action.click()
action.perform()

I've also tried clicking on other infobox elements using ActionChains or element.click(), all of them either do nothing or give a request error or aren't clickable at the point.

1 answers

0

As a last resort, you can use JS with execute_script:

wait = WebDriverWait(driver, 10)
actions = Actions(driver)
element = wait.until(EC.element_to_be_clickable((By.ID, 'infoboxmoreinfobtnbind')))

driver.execute_script("$(arguments[0]).click();", element)

This is not a humanlike automation but it should do the job...

Hope this helps you!