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
Selenium 量角器-CentOS 7中的铬合金无头量角器_Selenium_Selenium Webdriver_Protractor_Headless Browser_Google Chrome Headless - Fatal编程技术网

Selenium 量角器-CentOS 7中的铬合金无头量角器

Selenium 量角器-CentOS 7中的铬合金无头量角器,selenium,selenium-webdriver,protractor,headless-browser,google-chrome-headless,Selenium,Selenium Webdriver,Protractor,Headless Browser,Google Chrome Headless,我们正在尝试使用chromedriver在CentOS 7虚拟机的无头模式下执行量角器测试 版本: 量角器-5.4.0 节点-v6.14.3 黄瓜js-4.2.1 谷歌浏览器版本-谷歌浏览器68.0.3440.84 Webdriver管理器正在运行并显示以下信息 [bpmuser@bg-bpm-qa-jbpm6 ~]$ ps -eaf | grep java root 3692 3685 5 17:19 pts/0 00:00:01 java - Djava.securit

我们正在尝试使用chromedriver在CentOS 7虚拟机的无头模式下执行量角器测试

版本

量角器-5.4.0

节点-v6.14.3

黄瓜js-4.2.1

谷歌浏览器版本-谷歌浏览器68.0.3440.84

Webdriver管理器正在运行并显示以下信息

[bpmuser@bg-bpm-qa-jbpm6 ~]$ ps -eaf | grep java
root      3692  3685  5 17:19 pts/0    00:00:01 java - 
Djava.security.egd=file:///dev/./urandom -Dwebdriver.chrome.driver=/usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.41 -Dwebdriver.gecko.driver=/usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.21.0 -jar /usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.14.0.jar -port 4444
gravor.conf.js:

var Cucumber = require("./node_modules/cucumber");
var { defineSupportCode } = require("./node_modules/cucumber");
var reporter = require('./node_modules/cucumber-html-reporter');
var report = require("./node_modules/cucumber-html-report");
var cucumberReportOptions = {
   source: './reports/results.json',
   dest: './reports/results',
   name: "report_detailed.html",
   title: "CDocs Automation Report",
};
var cucumberReporteroptions = {
    theme: 'Bootstrap',
    jsonFile: './reports/results.json',
    output: './reports/results/report.html',
    screenshotsDirectory: './reports/screenshots/',
    storeScreenshots: true,
    reportSuiteAsScenarios: true,
    launchReport: false,
    metadata: {
        "App Version":"Angular 2.0",
        "Test Environment": "QA",
        "Browser": "Chrome",
        "Platform": process.platform,
        //"Parallel": "Scenarios",
        "Scenarios" : "TestCases",
        "Executed": "Local"
    }
};

exports.config = {
  //directConnect: true,
  useAllAngular2AppRoots: true,
  seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
  getPageTimeout: 60000,
  allScriptsTimeout: 500000,
  framework: "custom",
  // path relative to the current config file
   frameworkPath: require.resolve('./node_modules/protractor-cucumber- framework'),
//restartBrowserBetweenSuites: true,
capabilities: {
    browserName: 'chrome',
    chromeOptions: {
    args: [ 'headless' ]
 },
acceptSslCerts: true,
},

// Spec patterns are relative to this directory.
  specs: ['./features/ChangeView.feature',
 ],

//baseURL: 'http://localhost:8080/',
  onPrepare: function () {
  browser.baseUrl = "http://localhost:8080/";      
 },

 onComplete: () => {
  reporter.generate(cucumberReporteroptions); //invoke cucumber-html-reporter
  report
    .create(cucumberReportOptions)
    .then(function() {
      //invoke cucumber-html-report
      // creating two reports(optional) here, cucumber-html-report gives 
    directory already exists as cucumber-html-reporter already creates the html dir!
      // suggestion- use either one of the reports based on your needs
      console.log("cucumber_report.html created successfully!");
    })

    },
  cucumberOpts: {
   format: ['json:reports/results.json', 'pretty'],
   require: ['./features/step_definitions/content_step_definitions.js'],
   tags: true,
   profile: false,
   'no-source': true
   }
   };
但是,运行量角器仍然不起作用:

[bpmuser@bg-bpm-qa-jbpm6 bin]$ pwd
/usr/lib/node_modules/protractor/bin
[bpmuser@bg-bpm-qa-jbpm6 bin]$ ./protractor /home/bpmuser/docs/CDocsAutomation/protractor.conf.js
[18:10:33] I/launcher - Running 1 instances of WebDriver
[18:10:33] I/hosted - Using the selenium server at http://127.0.0.1:4444/wd/hub

这一步之后就没有进展了。不确定我哪里做错了。

尝试在配置中使用此选项

 capabilities: {
    browserName: 'chrome',

    chromeOptions: {
        args: [ "--headless", "--disable-gpu", "--window-size=800,600" ]
    }
}

希望这有助于解决相同的问题。您能在浏览器中正常运行吗?同样的设置在Windows 10中使用浏览器和无头。但不在CentOS 7中工作如果您以root用户身份运行测试,它将不会启动并使测试失败。创建另一个帐户并尝试运行测试。如果您以root用户身份运行chrome,您将遇到此问题。现在我得到“E/launcher-未知错误:chrome无法启动:异常退出”如何根据上述功能启动Xvfb?