Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 使用无头chrome显示页面的空白部分_Angularjs_Selenium_Protractor_Selenium Chromedriver - Fatal编程技术网

Angularjs 使用无头chrome显示页面的空白部分

Angularjs 使用无头chrome显示页面的空白部分,angularjs,selenium,protractor,selenium-chromedriver,Angularjs,Selenium,Protractor,Selenium Chromedriver,在量角器脚本中使用chromedriver时,为了测试角度页面,我使用“Headless”或“Normal”浏览器获得不同的结果 实际上,如果我使用“repeater”定位器来显示“empty”列表中的项目,它返回有5个项目,但“headless”chrome驱动程序无法呈现它们。请看屏幕截图 我使用的是ChromeDriver 2.45,它支持Chrome版本70到72,我有版本71。 我的操作系统是Windows10。 量角器版本5.1.1 Angularjs 1.5版 以下是配置文件: e

在量角器脚本中使用chromedriver时,为了测试角度页面,我使用“Headless”或“Normal”浏览器获得不同的结果

实际上,如果我使用“repeater”定位器来显示“empty”列表中的项目,它返回有5个项目,但“headless”chrome驱动程序无法呈现它们。请看屏幕截图

我使用的是ChromeDriver 2.45,它支持Chrome版本70到72,我有版本71。 我的操作系统是Windows10。 量角器版本5.1.1 Angularjs 1.5版

以下是配置文件:

exports.config = {
    directConnect: true,
    rootElement: 'html',
    chromeDriver: 'C:\\srv\\build\\applications\\chromedriver\\chromedriver_win32\\chromedriver.exe',
    getPageTimeout: 60000,
    allScriptsTimeout: 60000,
    framework: 'custom',
    frameworkPath: require.resolve('protractor-cucumber-framework'),
    capabilities: {
        'browserName': 'chrome',
            chromeOptions:{
              args:["--headless"]
            }
    },

specs: [ 'features/*.feature' ],
baseUrl: '',
cucumberOpts: {
    tags: '',
    require: [ 'steps/*.spec.js' ],
    monochrome: true,
    strict: true,
    plugin: "json"
 },
};



能否将参数更新为

capabilities: {
    ...,
    chromeOptions: {
        args: ["--headless", "--disable-gpu", "--window-size=800x600"]
    }
}
对于上面提到的精确配置,我能够无头自动化,没有任何问题


参考

似乎问题在于窗口大小。默认情况下,headless模式不是全屏模式,因此某些元素会自动移动和隐藏(当您尝试手动调整窗口大小时)

只需将以下内容添加到您的配置中:

driver.manage().window().maximize();