Protractor element not found using cssselector locator?

Raising my head around the protractor ... How can I access the button element on the corners page, which looks like this:

<button class="button primary">Save</button> 

Using this in my test:

 element(by.css('button primary')).click(); 

Getting error:

 NoSuchElementError: No element found using locator: By.cssSelector("button primary") 

How can i fix this?

+6
source share
3 answers
 element(by.css('button.button.primary')).click(); 
+7
source

element(by.buttonText('Save')).click();

+1
source

Depending on the state of the application, there are several selectors. Personally, since we say that I am developing a website with many buttons created with the same class (for styling, fonts, etc.), and it can be annoying when there can be more than one button on the same page by the same class, so you may want to give it a unique unique identifier or select the button text, which is easiest in my opinion:

 element(by.buttonText('Save')).click(); 

But this is a matter of preference, Only sharing my opinion. Have a nice day!:)

+1
source

Source: https://habr.com/ru/post/976395/


All Articles