Search code examples
pythonhtmlseleniumselenium-chromedriverangularjs-ng-click

Python Selenium ng-click action


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!


Solution

  • 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