selenium-cucumber-js icon indicating copy to clipboard operation
selenium-cucumber-js copied to clipboard

Assert and Expect

Open ahsan-babar opened this issue 7 years ago • 2 comments
trafficstars

I want to assert a heading's text on a webpage. I want to assert "Hi" from the heading. I tried like this: this.Then(/^I should see Hi$/m, function(){ driver.wait(until.elementsLocated(by.css('#body-section > div > div.row > div')), 10000); return driver.findElement(by.css('h3.RTL')).then(function(e){ expect(e.getText()).to.include('Hi'); }) });

Please help...

ahsan-babar avatar Dec 26 '17 07:12 ahsan-babar

Please clean up your post, it's hard to follow

john-doherty avatar Dec 26 '17 23:12 john-doherty

Could you please provide some examples of how to use assert in this? Like we use assert.Equals(expected, actual) in JAVA. This is what I'm doing at present: I load a page-->I provide login credentials --> I click login button---> I am redirected to my account ----> I click My Profile button ---->I provide text in some fields in a form---->I submit the form.

I want to assert that there exists a text "Hi "in heading of that webpage. I want to assert the successful response message that appears after submitting the form.

You can check yourself: Website: www.phptravels.net/login username: [email protected] password: demouser

ahsan-babar avatar Dec 27 '17 06:12 ahsan-babar