Saturday, October 19, 2019

Protractor Configuration With Eclipse




We can configure Protractor with Eclipse as mentioned the below steps:

Step1:

Download Node.js 7.7.3 from here. We need to download the older version of node because eclipse plugins are not working properly with new version of node.


Now install node.js after clicking on few next button.

We can verify the installation of the node.js using the following commands.


  • node -v or we can use node --version
  • npm -v or we can use npm –version

Step2:


Now we need to install protractor on our machine using the following command
  • npm install -g protractor or npm -g protractor@version


After installation we can find Protractor directory under this location


Now we need to type the following command to download drivers to run our script on firefox or chrome

  • webdriver-manager update




Download Eclipse Oxygen from here. We need to download the older version of Eclipse because required plugins for Protractor are not working properly on new version of Eclipse.

We can download Eclipse IDE for Java EE Developers or Eclipse IDE for JavaScript and Web Developers.

Step3:

Extract it and click on eclipse.exe to launch the IDE. 


NOTE : Sometimes it is showing some error for long path on extraction of zip file.

we can skip it or we can modify the group policies 


or tweak the registry as below


Step4:

We need to install the following plugin for Protractor

After launching the eclipse Go to Help -> Install New Software…


Now type URL for plugin http://oss.opensagres.fr/angularjs-eclipse/1.3.0-SNAPSHOT/

Now click on OK then click on Next now accept the Licenses.


Click on Install anyway to install this plugin

Then click on Restart Now option to complete the installation of this plugin


Now download the node eclipse plugin from Eclipse MarketPlace. 
Install this plugin as previously we have discussed.

Step 5: 

Now we will create a Sample Project to test Configuration.
Click on File -> Other -> Java Script Project



Click on Next and give a project name


and click on Finish button it may ask to open in JavaScript Perspective then click on Ok button.

Then Project will be created and available under project explorer section

Step 6:
Now Right Click on Project and choose Configure -> Convert to Tern Project


Select the following options
a. Angular JS
b. Jasmine
c. Node.js
d. Protractor



Step 7:
Copy this following 2 files from the below location and keep it under newly created project directory in eclipse. 



We will discuss it later in details of these 2 files for now we can say config.js is require for protractor configuration and example_spec.js is for testcases.

Copy the protractor modules to eclipse project folder structure.



Step 8:

Now Right click on project structure and click on the Run As -> Run Configurations…


Select the new Configuration for Protractor and Provide the following details.




We can also create a node runner as well use the following details as below





9 comments:

  1. Very Helpful...Thank you for sharing...Waiting for more protractor blogs...

    ReplyDelete
  2. Thank you for sharing. it was very helpful.

    ReplyDelete
  3. Thanks for the explanation, i am still having issues
    seems like node package error.. Could you please help me to resolve this.

    C:\Users\sis\eclipse-workspace\Protractor Tutorial\protractor\node_modules\find-up\index.js:29
    const foundPath = await runMatcher({...options, cwd: directory});
    ^^^
    SyntaxError: Unexpected token ...
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at pkgUp (C:\Users\sis\eclipse-workspace\Protractor Tutorial\protractor\node_modules\yargs\yargs.js:570:20)

    ReplyDelete
  4. Hi Arjun

    I am getting below error when i tried to install protractor:

    npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
    npm WARN deprecated har-validator@5.1.5: this library is no longer supported
    C:\Users\gadhu\AppData\Roaming\npm\protractor -> C:\Users\gadhu\AppData\Roaming\npm\node_modules\protractor\bin\protractor
    C:\Users\gadhu\AppData\Roaming\npm\webdriver-manager -> C:\Users\gadhu\AppData\Roaming\npm\node_modules\protractor\bin\webdriver-manager
    C:\Users\gadhu\AppData\Roaming\npm
    `-- protractor@7.0.0

    ReplyDelete
  5. Thanks for this blog. Very helpful! I have one query : Protractor module keeps showing some errors in eclipse. What is the reason for that and how to solve it?

    ReplyDelete
  6. adding http://oss.opensagres.fr/angularjs-eclipse/1.3.0-SNAPSHOT/ , submin button still showing disabled in eclipse . How do i add these plugins

    ReplyDelete
  7. Thanks and that i have a neat give: How Much Home Renovation Can I Afford house renovation contractors

    ReplyDelete