seleniumbase / SeleniumBase

📊 Blazing fast Python framework for web crawling, scraping, testing, and reporting. Supports pytest. Stealth abilities: UC Mode and CDP Mode.
https://seleniumbase.io
MIT License
5.43k stars 982 forks source link

[HELP] Using click on element with ng-click of Angular does not work #3193

Closed lomiz closed 1 month ago

lomiz commented 1 month ago

Hello, I'm using the latest version of SeleniumBase and when I click on this specific element: <span style="cursor:pointer;" ng-click="ctrl.ExampleClick()">clickable text inside the span</span>

with this command: mydrive.press_key('span:contains("clickable text inside the span")') it does not work. The same method work on other elements without the ng-click.

I suppose this problem is caused somewhat from the "ng-click" which it seems to call a javascript/angular functions.

What is the correct way to simulate the click of those kind of elements?

I tried with Selenium and I solved doing something like this:

e = browser.find_element(By.XPATH,"//span[text()='clickable text inside the span']")
browser.execute_script('arguments[0].click()',e)

Thank you for the support

mdmintz commented 1 month ago

There's no such press_key() method in SeleniumBase. See help_docs/method_summary.md for all methods. Maybe you meant to use the click() method.