How can I check if checkbox is checked with Protractor, CucumberJS and Chai?
isSelected()
would do that:
this.expect(element(by.model(el)).isSelected()).to.eventually.be.true;
Protractor Check if Element Does Not Exist
Got the thing working by using something I found in the docs:
expect(element(by.css('.switch')).isPresent()).to.become(false).and.notify(next);
Also uses assertions, so it doesn't break cucumberjs.
How to check whether the element exist using chai?
The exist
language chain in vanilla Chai is used to verify that a plain old JavaScript object is neither undefined
nor null
. It sounds like in your case you actually want to be asserting against a DOM element, which vanilla Chai can't do. Instead, you'll need to pull in a Chai plugin like chai-jquery
along with jQuery
for DOM manipulation. chai-jquery
allows you to write assertions against elements you have located using jQuery
, and even provides and overriden form of exist
that would likely serve your purpose exactly. All together, the code you're looking for to assert a div
with class avatar
exists would look something like this:
expect($('div.avatar')).to.exist;
Chai expect - expect(browser.getTitle()) errors with - browser.getTitle is not a function
browser
is global variable, you can use it directly without to require it. Thus following line is unnecessary:
const browser = require('protractor');
Related Topics
Disabled Button Onclick Event Fires
How to Do Validation for 10 Digit Mobile Number Using Jquery
Why Is It a Bad Practice to Return Generated HTML Instead of Json or Is It
Hosting Your Own JavaScript Scripts Files (Other Than Jquery) on Fast Free Cdns Like Google
Reactjs Dynamic Drop Down Populated With Map Function
Detect Click into Iframe Using JavaScript
How to Close Current Tab in a Browser Window
Change Image on Scroll Position
Converting Excel Date Serial Number to Date Using JavaScript
Why Am I Not Able to Add Input Text into My Table
How to Call a Function When Element Is Loaded At Angular
How to Escape an Ampersand in a JavaScript String So That the Page Will Validate Strict
Javascript, Track Iframes Redirecting Top Window
How to Remove a Parameter from a Url
Detect If Page Is Load from Back Button
How to Prevent Drag on a Child, But Allow Drag on the Parent
How to Make Some Text from a Json String Bold
Why Am I Getting Undefined as an Answer When Fetching Data from an API