Lakmal Rajith
Lakmal Rajith

Reputation: 71

Protractor tests can not intiated for firefox browser

I am currently trying to launch protractor e2e tests on Firefox web browser , however i got this error, can any one have an idea to solve this issue? Thanks for your time

[webdriver-start] Running Firefox as root in a regular user's session is not supported.  ($HOME is /Users/x which is owned by x)
[protractor    ] [19:38:09] E/launcher - invalid argument: can't kill an exited process
[protractor    ] Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
[protractor    ] System info: host: 'MacBook-Pro.local', ip: '192.168.1.3', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_151'
[protractor    ] Driver info: driver.version: unknown

Upvotes: 0

Views: 622

Answers (2)

Sameera De Silva
Sameera De Silva

Reputation: 2000

Here is a working example for Firefox which I tested recently in the latest protractor . Make sure that you have the latest version of Firefox and protractor. Mine is
protractor -Version 5.4.2 and Firefox 71 browser version.

Please see the sample config,js and read the comments to get an Idea.

//protractor firefoxconfig.js
exports.config = {
  framework: 'jasmine',
  directConnect: false, //Start protractor without start the selenium server using webdriver-manager start. default value is fales
  //This is  only for chrome and firefox and use drivers instead of selenium server

  capabilities: {
      browserName: 'firefox',
      'moz:firefoxOptions': {
            args: ['--verbose'],
            binary: 'C:/Program Files/Mozilla Firefox/firefox.exe' //Provide binary location to avoid potential binary not found errors 
       //Need to start cmd via admin mode to avoid permission error
        }
},   
    //set to true So each spec will be executed in own browser instance. default value is false
    //restartBrowserBetweenTests: true,
     jasmineNodeOpts: {
    //Jasmine provides only one timeout option  timeout in milliseconds don't add ;
    defaultTimeoutInterval: 180000
     },

  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['src/com/sam/scriptjs/iframes.spec.js']

}

Further readings - https://medium.com/@smeesheady/how-to-setup-protractor-to-run-in-firefox-browser-138046214e1 How can I configure the firefox binary location in Protractor?

Upvotes: 1

Sankalan Parajuli
Sankalan Parajuli

Reputation: 690

Read the comments and saw that you got the answer to your question. The answer to your question in the comment is as follows:

To run both FF and Chrome on headless in the same tests, you will need to add something called multiCapabilities in your configuration. Here is a code snippet:

    multiCapabilities: [
        {
            browserName: 'chrome',
            chromeOptions: {
                args: [
                    "--headless", '--disable-gpu'
                ]
            },
            shardTestFiles: true,
            maxInstances: 4,
            platformName: "OS X 10.9",
            version: '63.0'
        },
        {
            browserName: 'firefox',
            'moz:firefoxOptions': {
                'args': [
                    "--headless"
                ]
            },
            shardTestFiles: true,
            maxInstances: 4
        },
        {
            browserName: 'safari',
            'safari.options': {
                cleanSession: true
            }
        }],

This way you can run multiple browsers together.

Upvotes: 1

Related Questions