0

Code Snippet:

<div class="add create_Amenities" hs-gesture="{handler:showPopup, param:menu_group}" ng-if="showPlus(menu_group,$index)">

Using the following Command in Protractor but with no success. Action: An add (+) button must be clicked by this command.

Reason: No Element Found using locator: By (css selector, .add create_Amenities)

element(by.css('.add create_Amenities')).click();
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Kevin
  • 95
  • 3
  • 7

1 Answers1

1

.add create_Amenities

This is not going to match the desired element. What it would do literally is to find create_Amenities element (imagine <create_Amenities>...</create_Amenities>) under the element with add class.

Instead, you meant:

.add.create_Amenities

There is also a $ shortcut in Protractor, you can do:

$(".add.create_Amenities").click();

As for your separate question, it would still be a shot in the dark, but you can try the following:

  • click via javascript:

    var elm = $(".add.create_Amenities");
    browser.executeScript("arguments[0].click();", elm)
    
  • move to element and then click:

    browser.actions().mouseMove(elm).click().perform(‌​);
    
Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Thanks for you Reply: I tried both of your suggestions.... The button was NOT clicked .... No error was generated this time – Kevin Apr 22 '16 at 13:38
  • @Kevin but you don't get the error you were getting before, right? The problem you are describing now sounds like a separate issue. Are you sure the click on this particular element should lead to something on the page? Please recheck what element you need to click..may be an element inside this `div`? – alecxe Apr 22 '16 at 13:47
  • Alecxe: Yes, Click on the "+" button should lead to another page. I am not getting the error that I was getting before. My button may need a double click on the button... tried the following and did not work either. I am not getting any error for this command either. browser.driver.actions().doubleClick(element(by.css('.add.create_Amenities'))).perform(); – Kevin Apr 22 '16 at 13:57
  • @Kevin have u tried to move to the element and then click? (In a similar way via browser.actions()) – alecxe Apr 22 '16 at 14:00
  • No Luck with the following either: browser.actions().doubleClick(element(by.css('.add.create_Amenities'))).perform(); – Kevin Apr 22 '16 at 14:12
  • @ alecxe: Your solution to use the click via javascript did not work (syntax Error). Also, as I understand it the javascript click does not really simulate the click. I like to see if I can find a solution through webdriver to reproduce what a user would do with the browser. Thanks for trying – Kevin Apr 22 '16 at 14:50
  • browser.driver.actions().mouseMove(element(by.css('.add.create_Amenities'))).perform(); element.all(by.css('.add.create_Amenities')).then(function (elm) { elm[0].click(); }); I enter the above command, my browser come up but I have to manually click on the “+” button to proceed to the next page: Question: How can I make this command a double clicked on the (+) button. I tried it different ways but I was not successful. Any ideas??? My Code Snippet is on the top of the page. – Kevin Apr 22 '16 at 19:50
  • @Kevin okay, let's not try to solve follow-up problems in comments. Please consider creating a separate question providing all the necessary details. Thanks for understanding. – alecxe Apr 22 '16 at 19:51