Our dev has a submit button like this:
<button _ngcontent-c6="" class="btn btn-block btn-primary mt-lg" type="submit">Login</button>
I tried using:
element(by.buttonText('#submit'));
but no luck with it.
Note: I'm new to protractor.
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityUse the following cssSelector:
var loginBtn = element(by.css(button[type = 'submit']));
It seems there is mismatch. You are trying to use ID as text which is incorrect.
If you want to use by.buttonText
then your code should be by.buttonText('Login')
Or you can also use css selector like element(by.css(button[type = 'submit']));
I prefer to use submit property in this scenario instead of button text as it is less fragile as it is less likely to be changed compared to text.
I would use precisely:
$('button[type="submit"]')
You can use this
element(by.xpath('//button[contains(text(),"Login")]')).click();
buttonText
locator, you give the text of button, not the id. Try usingby.buttonText('Login')