Installing Protractor
To set up protractor, we need to install below three
things :
1. Node.js
2. Protractor
3. Selenium Webdriver
Step 1: Node.js Setup
- First we have to
install NodeJS.
(https://nodejs.org/en/download/)
- Click on Windows
Installer
- Once the download has finished , proceed to installation
by click on downloaded exe file .
- Now to see if the installation is done successfully, you
can go and check in variables. The path
will be defined automatically. To open
system environment : Click on Start >
select Control Panel >double click System > select the Advanced tab Or
You can also check from the command prompt by typing the
command 'npm -version ' and press Enter
in command prompt
Step 2: Protractor
Setup
- To install protractor globally we need to use “npm install
–g protractor” in cmd
-To check version of protractor we have to use –
“protractor--version”
Step 3: Webdriver
Setup
- To install Webdriver , we need to use “npm install -g
webdriver-manager” in cmd
- To setting up selenium server , we need to use
“webdriver-manager update” in cmd
-Before running any protractor script we need to turn on
selenium server with command
“webdriver- manager start”
Use below code as test.spec
describe('angularjs homepage todo list', function() {
it('should add a
todo', function() {
browser.get('https://angularjs.org');
element(by.model('todoList.todoText')).sendKeys('write first protractor
test');
element(by.css('[value="add"]')).click();
var todoList =
element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write
first protractor test');
// You wrote your
first test, cross it off the list
todoList.get(2).element(by.css('input')).click();
var
completedAmount = element.all(by.css('.done-true'));
expect(completedAmount.count()).toEqual(2);
});
});
and below code as conf.js
exports.config = {
seleniumAddress:
'http://localhost:4444/wd/hub',
specs:
['todo-spec.js']
};
Try both code keep in npm folder if network securities are
more in your office
run the code using CMD by reaching in folder
"protractor conf.js"
Now with integrated with Eclipse try below steps
Yes, you can use protractor plugin in eclipse.
1. Go to
help-->Marketplace
2. Search for
tern.java
3. Install Tern
Eclipse IDE
4. and accept the
licence.
Now create a project in eclipse
5. Right click on
project-JS project,
6. Add node_module
from c folder to eclipse, add above 2 files in project
Installing Protractor
To set up protractor, we need to install below three
things :
1. Node.js
2. Protractor
3. Selenium Webdriver
Step 1: Node.js Setup
- First we have to
install NodeJS.
(https://nodejs.org/en/download/)
- Click on Windows
Installer
- Once the download has finished , proceed to installation
by click on downloaded exe file .
- Now to see if the installation is done successfully, you
can go and check in variables. The path
will be defined automatically. To open
system environment : Click on Start >
select Control Panel >double click System > select the Advanced tab Or
You can also check from the command prompt by typing the
command 'npm -version ' and press Enter
in command prompt
Step 2: Protractor
Setup
- To install protractor globally we need to use “npm install
–g protractor” in cmd
-To check version of protractor we have to use –
“protractor--version”
Step 3: Webdriver
Setup
- To install Webdriver , we need to use “npm install -g
webdriver-manager” in cmd
- To setting up selenium server , we need to use
“webdriver-manager update” in cmd
-Before running any protractor script we need to turn on
selenium server with command
“webdriver- manager start”
Use below code as test.spec
describe('angularjs homepage todo list', function() {
it('should add a
todo', function() {
browser.get('https://angularjs.org');
element(by.model('todoList.todoText')).sendKeys('write first protractor
test');
element(by.css('[value="add"]')).click();
var todoList =
element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write
first protractor test');
// You wrote your
first test, cross it off the list
todoList.get(2).element(by.css('input')).click();
var
completedAmount = element.all(by.css('.done-true'));
expect(completedAmount.count()).toEqual(2);
});
});
and below code as conf.js
exports.config = {
seleniumAddress:
'http://localhost:4444/wd/hub',
specs:
['todo-spec.js']
};
Try both code keep in npm folder if network securities are
more in your office
run the code using CMD by reaching in folder
protractor conf.js
Now with integrated with Eclipse try below steps
Yes, you can use protractor plugin in eclipse.
1. Go to
help-->Marketplace
2. Search for
tern.java
3. Install Tern
Eclipse IDE
4. and accept the
licence.
Now create a project in eclipse
5. Right click on
project-JS project,
6. Add node_module
from c folder to eclipse, add above 2 files in project
7. Mouse hover to configure and
Click on convert
to tern project
8. Right click and click Run as configure add
main tab as conf.js and project name in directory
and protractor
tab as cli.js(go till node module),click on Done, select protractor and save
9. RUn the script
using eclipse
No comments:
Post a Comment