Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chained scripts in package.json is not executing properly

Tags:

protractor

I am trying to run my Protractor test from command line using package.json.

My package.json looks like below -

{
    "name": "ProtractorFramework",
    "dependencies": {
        "protractor": "^5.4.1"
    },

    "scripts": {    
    "webdriver-manager-update":"./node_modules/.bin/webdriver-manager update",
    "webdriver-manager-start":"./node_modules/.bin/webdriver-manager start",
    "protractor":"./node_modules/.bin/protractor configuration.js",
    "start":"npm run webdriver-manager-update && npm run webdriver-manager-start && npm run protractor"


}
}

When I execute the below command -

npm run start from Project directory, the Selenium Standalone server is up, but the last command is not getting executed. It means, the browser is not opening.

To execute the test/open the browser, I am forced to execute npm run protractor separately in another command window.

Is there any mistake in my package.json that I am unable to execute all three commands together?

Please help.

like image 627
Prabodh Ghosh Avatar asked Nov 25 '25 08:11

Prabodh Ghosh


1 Answers

Prabodh you can't chain the selenium server startup command and the test execute command.

webdriver-manager start start up a Selenium Server and will output a bunch of info logs. Your Protractor test will send requests to this server to control a local browser. Leave this server running.

When you run webdriver-manager start selenium server will run in the command prompt. This command prompt can't be closed if you close it then selenium server will be quit.

Instead you can create a script that will open a new command prompt and run the webdriver-manager start command like

  "scripts": {    
       ..... 
       "wdstart":"start cmd /k webdriver-manager start timeout 10 && npm run protractor"
        ......
       }
like image 177
Bharath Kumar S Avatar answered Nov 28 '25 16:11

Bharath Kumar S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!