Kevin
Kevin

Reputation: 95

Find Element by Class

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();

Upvotes: 0

Views: 120

Answers (1)

alecxe
alecxe

Reputation: 473823

.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(‌​);
    

Upvotes: 1

Related Questions