0
<a class="btn btn-xs btn-success" href="/user-location-auth/location?id=4013" 
title="View User Location Access" data-toggle="tooltip" data-method="post"> 
<span class="glyphicon glyphicon-map-marker"></span></a>    <span 
class="glyphicon glyphicon-map-marker"></span>        <<pseudo:before>> 
</<pseudo:before>>

Hi all, I have been tasked with a project that requires clicking on a button in a table (with 14 cells). The first 13 cells are all unhidden, but the 14th one (where the buttons are located), are hidden unfortunately. I have tried action chains, I have tried hovering over the element and then clicking on it. I seem to be at a loss here. This piece of code did work, however I want to avoid using javascript as I want to replicate a user experience.

z4 = driver.find_element_by_css_selector('a.btn-success > span.glyphicon-map-marker')
driver.execute_script('arguments[0].click();', z4)
11
  • where is javascriptExecutor involved in this code ? Commented Jul 12, 2018 at 16:29
  • I'm sorry, just added the correct code to execute using javascript. Commented Jul 12, 2018 at 16:35
  • what happens when you use this code z4.click() instead of driver.execute_script('arguments[0].click();', z4) Commented Jul 12, 2018 at 16:37
  • I get the following exception: ElementNotVisibleException Commented Jul 12, 2018 at 16:42
  • z4= WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'a.btn-success > span.glyphicon-map-marker'))) Commented Jul 12, 2018 at 16:44

1 Answer 1

1

Hi everyone and cruisepandey, I found a solution that works. First, I waited for the presence of the element to be located. Once that occurred, I grabbed the element and moved to it with ActionChains (I think I was misusing ActionChains earlier). Then I was able to click on the Bootstrap button.

WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, """
//tr[@data-key='2312312321321']/td/a[contains(@class, 'btn-xs btn- 
success')]/span[contains(@class, 'glyphicon')]""")))

y = driver.find_element(By.XPATH, """//tr[@data- 
key='2312312321321']/td/a[contains(@class, 'btn-xs btn- 
success')]/span[contains(@class, 'glyphicon')]""")

#Use action chains to click on the button
ActionChains(driver).move_to_element(y).click().perform()
Sign up to request clarification or add additional context in comments.

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.