0

Good day!

I'm switching off SELENIUM_PROMISE_MANAGER in protractor jasmine conf due to #2969

In my PageObject methods I have a setter, which make "sendKeys" in textBox elements from object literal passed to this setter, like:

set informationSection(object) {
   for (let element in object) {
      this[element].sendKeys(object[element]);
   }
}

and in testCase:

it('description of spec', async() => {
   const information = {
       field1: 'Field 1 description,
       field2: 'Field 2 description,
   };

   await mainPage.openInformationDialod();

   //Here need to call setter
   mainPage.informationSection = information;

   await mainPage.apply();
})

In this example I expect that firstly will "sendKeys" from setter, and then "apply" method. But setter works synchronously, and sometimes it finished after "mainPage.apply()".

In case of usage protractor control flow there are no such problem. Does anybody know something workaround which allow to push setter inside async stack?

Thank you in advance.

1 Answers1

0

You should await the sendKeys() also:

set async informationSection(object) {
   for (let element in object) {
      await this[element].sendKeys(object[element]);
   }
}
Oleksii
  • 1,623
  • 20
  • 26
  • But async keyword is not possible for setters in typescript. – Stanislav Kharchenko Jul 09 '18 at 11:35
  • change it to common function ;) – Oleksii Jul 09 '18 at 11:38
  • What does it mean? Yes, I can use something like Object.defineProperty with set: async function(...) {...} but how to use "await" when set property? The construction like "await mainPage.informationSection = information" is also invalid – Stanislav Kharchenko Jul 09 '18 at 13:15
  • The similar question, how to just fill single web element within setter and async/await. Like mainPage.lastName = "John Smith", where lastName is property, which has setter with "sendKeys". I'm surprised by desire to remove promise manager in protractor, since, it obviously, something approach can't be implemented... – Stanislav Kharchenko Jul 13 '18 at 10:46