0

Currently im using an object modelling approach to replicate pages and initialising the chai libraries within the wdio file however my method seems to be failing, any ideas?

Method:

confirmSuccessfulSubmission() {
    const successfulSubmissionHeader = $('#contact_reply h1');
    console.log("TEST2: " + successfulSubmissionHeader);
    console.log("TEST2: " + successfulSubmissionHeader.getText());
    successfulSubmissionHeader.should.equal('Thank You for your Message!');
    // successfulSubmissionHeader.waitForDisplayed(3000);
    // expect(successfulSubmissionHeader).to.equal('Thank You for your Message!');
}

Output of test execution:

2019-02-21T21:14:16.752Z INFO wdio-cli:Launcher: Run onPrepare hook
2019-02-21T21:14:20.660Z INFO wdio-local-runner: Start worker 0-0 with arg:
[0-0] TEST2: [object Object]
[0-0] TEST2: Thank You for your Message!
2019-02-21T21:14:30.098Z DEBUG wdio-local-runner: Runner 0-0 finished with exit code 1
2019-02-21T21:14:30.106Z INFO wdio-cli:Launcher: Run onComplete hook

thanks for your help

SamP
  • 417
  • 5
  • 24

1 Answers1

2

Based on these lines:

 console.log("TEST2: " + successfulSubmissionHeader);
 console.log("TEST2: " + successfulSubmissionHeader.getText());

returning this output:

[0-0] TEST2: [object Object]
[0-0] TEST2: Thank You for your Message!

It look like in this line:

successfulSubmissionHeader.should.equal('Thank You for your Message!');

you are comparing the object successfulSubmissionHeader to the string 'Thank You for your Message!', I don't think that's what you meant to do.

Use

expect(successfulSubmissionHeader.getText()).to.equal('Thank You for your Message!');

to compare the text of the element to the string instead.

Gilad Shnoor
  • 374
  • 3
  • 12