量角器测试用例不在无头模式下运行

时间:2019-09-03 14:14:38

标签: selenium protractor headless

量角器测试用例在浏览器打开的情况下运行良好,但并非处于无头模式。

我尝试过在不同的选择器和睡眠浏览器方法下运行量角器测试用例,但是它在任何情况下都无法在无头模式下工作。 我正在使用docker setup运行它。

it('should show profile link', async function() {


await action.waitForSelector(map.homePage.my_profile, config.credentials.min_timeout);


await action.checkElementPresent(map.homePage.my_profile, 'profile link');
    });


Error: should show profile link

       Failed: Did not find element: .my-profile

       Wait timed out after 2000ms

       Wait timed out after 2000ms

在断言选择器时会出现上述错误,并且如果在打开浏览器的情况下运行测试,则可以正常工作。在无头模式下找不到选择器。

1 个答案:

答案 0 :(得分:0)

在conf.js中下面提到的代码段之类的功能下设置browserOption-可能有帮助

chromeOptions: {
        args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage', '--disable-browser-side-navigation', '--disable-setuid-sandbox', '--disable-gpu', '--ignore-certificate-errors', '--ignore-ssl-errors', '--disable-infobars=true'],
    }