Protractor unable to find elements and script timeout

前端 未结 1 1611
时光取名叫无心
时光取名叫无心 2021-01-21 20:26

I\'m running protractor, it runs successfully and load my angular app. The very first test I wrote is to get the sign-up button. Although I can see the sign-up button in my view

相关标签:
1条回答
  • 2021-01-21 20:40

    Updated some syntax and removed async/awaits from page object function.

    As I mentioned your failure is likely due to an async issue. Can you try changing your code to disable the promise_manager in the conf and use the async/await syntax and see if that helps you?

    a previous answer of mine on the subject of the async/await & the promise manager

    Every action that interacts with the browser will need an await before it and every function that contains an await will need to be labeled async

    Conf.js

    exports.config = {
        framework: 'jasmine',
        specs: ['./app.js'],
        // specs: ['./app.js','./app.1.js'],
        seleniumAddress: 'http://localhost:4444/wd/hub',
        SELENIUM_PROMISE_MANAGER: false
    }
    

    Page Object

    getButtonText() {
      return element(by.css('a[data-e2e="nav-signup"]')).getText();
    }
    
    navigateTo() {
      return browser.get('/');
    }
    

    Spec File

    it('should get the text of sign up button', async () => {
      await page.navigateTo();
      expect(await page.getButtonText()).toEqual('Sign up');
    });
    
    0 讨论(0)
提交回复
热议问题