I am not able to click on element using any of the locators only javascript executor works for me in angular 2 pages
See original GitHub issueHere is my html for angular 2 applications. I am executing my tests in chrome
<md-card-title _ngcontent-c10="" class="ra-card-title mat-card-title">
<a _ngcontent-c10="">Massachusetts Division of Banks Issues Decision Establishing Limit on Maximum Allowable Fee for Dishonored Checks for State - Chartered Financial Institutions</a>
</md-card-title>
<div _ngcontent-c10="" class="ra-card-header__footer">
<md-card-subtitle _ngcontent-c10="" class="ra-card-code mat-card-subtitle">BLN3594</md-card-subtitle>
<div _ngcontent-c10="" class="ra-card-menu">
<span _ngcontent-c10="" aria-haspopup="true" class="ra-card-menu-button">...</span>
<md-menu _ngcontent-c10="" role="menu" xposition="before" yposition="below"><!----> </md-menu>
</div>
</div>
<md-card-subtitle _ngcontent-c10="" class="ra-card-code mat-card-subtitle">BLN3594</md-card-subtitle>
I am not able to click on the menu button using
element(by.xpath("//span[@class='ra-card-menu-button'])[0]")).click();
But if I use below javascript executor , it is working fine.
var scrpt = "return document.getElementsByClassName('ra-card-menu-button')[0].click();";
browser.executeScript(scrpt).then(function (text) {
logger.log('info', 'Script is: ' + scrpt);
});
protractor version is 5.1.1.
Could anyone please help me to identify the issue
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
How to force Selenium WebDriver to click on element which is ...
Selenium determines an element is visible or not by the following criteria (use a DOM inspector to determine what css applies to your...
Read more >How do I resolve the ElementNotInteractableException in ...
1. Wait until an element is visible / clickable WebDriverWait wait = new WebDriverWait(driver, timeout); wait.until(ExpectedConditions. · 2.
Read more >JavascriptExecutor in Selenium Complete Guide
First of all, let's open Chrome developer tools then click the source tab. You will see the JavaScript codes. JavascriptExecutor in Selenium. In ......
Read more >Testing Angular Applications with Selenium Java - Medium
Solution: Use JavascriptExecutor library. At times locating the web elements using locators like XPath, CSS, etc might not work as expected, especially when...
Read more >How To Use JavaScriptExecutor in Selenium WebDriver?
At times, the click() method may not work on all the web browsers or the web controls might behave differently on different browsers....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Because by CSS means that you need to provide a
.
for classes and a#
for ID’s. Now you are looking for the TAGra-card-menu-button
, you should useelement(by.css('.ra-card-menu-button')).click();
Don’t
then()
here@Shobysukumaran Actually we have 400+ tests in out framework & it is extremly difficult to go & change each & every script to update the click(). 😦 Is there anything that I should update apart from Script.