0

I am new to Serenity and Protractor, so need your help for below query. Using - Protractor, Chai assertion, Screenplay serenity, Cucumber, TypeScript

I have below 2 locators in my locator file:

static test1 = Target.the("test1).located(by.xpath(...**...);

static test2 = Target.the("test2).located(by.xpath(...**...);

I have to compare test1 and test2 values.

Steps.ts file:

expect(actor.toSee(Text.of(locatorClass.test1))).to.eventually.equal("21");

If I am passing some constant value, it's working. but I have to pass other locator. How can I compare this two locators?

alseether
  • 1,889
  • 2
  • 24
  • 39
Upa A
  • 3
  • 3

1 Answers1

0

I'm not familiar with serenityjs, but the problem is that you are trying to compare result of promise (getting text from test 1) with unresolved promise (getting text from test 1).

You have two possibilities: 1. Resolve both promises and compare values (using chai). 2. Resolve one of promises and compare value with another promise (using chai-as-promise).

Below you can see my proposal (2nd option). test1 promise is resolved and stored as test1text and than compared to the second promise.

static test1 = Target.the("test1).located(by.xpath(...**...);
static test2 = Target.the("test2).located(by.xpath(...**...);

return actor.toSee(Text.of(locatorClass.test1)).then((test1text) => {
    return expect(actor.toSee(Text.of(locatorClass.test2))).to.eventually.equal(test1text);
});
Kacper
  • 1,201
  • 1
  • 9
  • 21