1

I am having a problem with my Protractor script. When i run each of the awaits i need them to have completed before the next one has started. Some of the functions being run take time to complete (upto 60 seconds). The problem is not the awaits seem to be waiting for the previous one to complete before running themselves. Does anyone have any ideas? Much appreciated!

*The webpage used in the code is a dummy one as the one i am using is locally held and wouldn't show for anyone trying this

describe('Verify title in the webpage', function () {

    //   ############### Environment Setup ####################

    it('Verify title of Test webpage', async function (done) {

        await fileLink.invokeJetState("Idle", browser.params.printerName) // ("Desired JetState", Printer IP/Name)
        await fileLink.invokeError("7", browser.params.printerName) // ("Index_No", Printer IP/Name)
        await browser.get('https://www.webpagetest.org/'); //Launch Browser and load webpage

        // Verify correct data is held within title bar
        await expect(browser.getTitle()).toBe('Application 1');
        done();

        await fileLink.invokeReboot(browser.params.printerName)

    });


});
  • 2 things it might be. 1. `await` does nothing if the argument is not a Promise. Are you sure all the functions are returning Promises? 2. You should not use `done` when your test is async. See https://stackoverflow.com/a/52449252/8887313 – ATOMP Jul 20 '21 at 14:09
  • Could you attach some debugging output? It's not easy to identify exactly what's wrong without knowing whether your custom functions are returning Promises. – ATOMP Jul 20 '21 at 14:11
  • Thanks for your suggestions, i shall double check my promises are all closed off and i shall remove done Also because i am running this code using Protractor it doesnt provide me with much in the way of useful debug – Cameron Taylor Jul 21 '21 at 08:45
  • I forgot to include it in the original code but where "fileLink" is shown it is connecting to another .js file where all my functions are held. These have "await" against them in the code above but they are underlined with "await has no effect on the type of this expression" and as a result they are all being run at once. Does anyone know how i can change these await calls to make them take effect? – Cameron Taylor Jul 28 '21 at 10:28
  • `await` only works on `Promise`. https://stackoverflow.com/a/60368041/8887313. They might have a callback? If so, you need to wrap in a `Promise`. ex: https://stackoverflow.com/a/46933884/8887313 – ATOMP Jul 28 '21 at 15:35

0 Answers0