protractor tests with headless chrome unable run element not found issue

643 views
Skip to first unread message

uday kiran

unread,
Oct 16, 2017, 9:39:01 AM10/16/17
to Chromium-discuss
Hi Team 

Need Help in running protractor tests with headless chrome. element not found issue

currently i am smoothly run my protractor test without headless chrome so i tried out headless in with i am getting element not found error
here is my config file setting
/Start- summary report/
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var reporter = new HtmlScreenshotReporter({
dest: 'summary/',
filename: 'summary-report.html',
showSummary:true
});
/End- summary report/
exports.config = {
directConnect: true,
//rootElement: 'html',
capabilities: {
'browserName': 'chrome',
  'chromeOptions': {
    'args': [ "--headless"]
    //"--disable-gpu", 
    //, "--window-size=800x600"
  }
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine2',
// Spec patterns are relative to the current working directory when
// protractor is called.
//specs: ['Test/testcases.js'],
specs: ['testcases.js'],
getPageTimeout: 180000,
allScriptsTimeout: 180000,
jasmineNodeOpts: {
defaultTimeoutInterval: 540000
},
/Start- summary report/
// Setup the report before any tests start
beforeLaunch: function() {
return new Promise(function(resolve){
reporter.beforeLaunch(resolve);
});
},
// Assign the test reporter to each running instance
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/',
takeScreenshots:false
}));
jasmine.getEnv().addReporter(reporter);
},
// Close the report after all tests finish
afterLaunch: function(exitCode) {
return new Promise(function(resolve){
reporter.afterLaunch(resolve.bind(this, exitCode));
});
}
};
and my testcase.js is this

describe('login', function() {
    it('Should login and verify success', function() {
        browser.get('https://localhost:3000');
        helpers.waitForElement(element(by.id('logIn')),5000);
        element(by.id('logIn')).click();
        helpers.waitForElement(element(by.model('user.username')),5000).then(function(){
        element(by.model('user.username')).sendKeys(USERNAME).
            then(function(){
                helpers.waitForElement(element(by.model('user.password')),5000);
                element(by.model('user.password')).sendKeys(PASSWORD).
                    then(function(){
                        helpers.waitForElement(element(by.id('tryLogin')),5000);
                        element(by.id('tryLogin')).click()
                    });
                });
        });
    });
});

Thanks

Rudy Caveda

unread,
May 6, 2018, 1:46:13 AM5/6/18
to Chromium-discuss, udayk...@gmail.com
Hey, guys I am getting the same issue. 

If I run chrome in headless I am getting the element not found on "browser.actions()" with mouseOver. 

Here's my config:

exports.config = {
// Address of a running selenium server - "webdriver-manager start"
seleniumAddress: 'http://localhost:4444/wd/hub',
// Specs to run when calling this file with Protractor
specs: ['services/**/*-spec.js'],
suites: {
//SOME SUITES HERE
},
onPrepare: function () {
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: true
}
}));
},
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': [ "--headless", "--disable-gpu", "--window-size=800x600" ]
}
}
};


If anyone can provide insight it would be greatly appreciated. 

Rudy Caveda

unread,
May 6, 2018, 1:46:13 AM5/6/18
to Chromium-discuss, udayk...@gmail.com
Found out it 


On Monday, October 16, 2017 at 9:39:01 AM UTC-4, uday kiran wrote:
Hi Team was my screen size :) I am good to go
Reply all
Reply to author
Forward
0 new messages