seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
5.33k stars 980 forks source link

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

Closed lomiz closed 2 weeks ago

lomiz commented 2 weeks 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 2 weeks 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.