4

I've been searching for a solution here on Stackoverflow or Google, but unfortunately I couldn't find any solution. I'm trying to do webscrape on a website, but I can not click on a button with Python + Selenium + Chrome webdriver.

The HTML code on the website:

<button type="button" ng-click="launch()" title="HTTP/HTTPS: WebSQL">
<div class="flex-column-centered">
    <f-icon class="bookmark-icon-large fa-globe" ng-class="TYPE_MAP[bookmark.apptype].icon"></f-icon>
    <span class="ng-binding">WebSQL</span>
</div> </button>

I understand that is AngularJS and I tried CSS selector and Xpath, none of these seem to work in my case. Any help would be appreciated!

1 Answer 1

2

Can you try this xpath :

//span[text()='WebSQL']/../..

I would suggest you to have explicit wait like this :

WebDriverWait(driver , 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='WebSQL']/../.."))).click()

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Sign up to request clarification or add additional context in comments.

3 Comments

It worked, thanks! Can you explain to me, what this means "/../.." in the regular expression?
/.. means that you wanna go to parent from the current node.
That makes sense, and actually a clever way to find the button element.

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.