Reputation: 383
how to synchronize the it blocks,
var kc = 1;
describe('angularjs homepage todo list', function() {
for(var i=0;i<5;i++){
it('should add a todo', function() {
kc = 10;
hello = 10;
});
}
});
describe('Print kc',function(){
var k = kc1();
expect(kc).toEqual(10);
});
Output: Value of kc is : 1
expected : Value of kc is : 10
Upvotes: 0
Views: 184
Reputation: 6277
If I'm understanding you correctly, then you want to store a value in a variable and access it in different describe
s.
You can use browser.params
to store a "global" variable. Then you need to add the params
attribute to your protractor-config
:
...
params: {
kc: 1
}
...
Now you can access your variable with browser.params.kc
, so your code would look like this:
describe('angularjs homepage todo list', function() {
for(var i=0;i<5;i++){
it('should add a todo', function() {
browser.params.kc = 10;
hello = 10;
});
}
});
describe('Print kc',function(){
var k = kc1();
expect(browser.params.kc).toEqual(10);
});
The advantage of using browser.params
to store your value is that you can pass another value directly to the protractor instance like:
protractor protractor-config.js --params.kc 5
<- kc now has the value 5
Does this help? Or did i misunderstood you?
Upvotes: 1