I am unable to use synchronous functions and asynchronous functions of JavaScript in protractor-cucumber...
up vote
0
down vote
favorite
I am using JavaScript for my protractor cucumber framework.the synchronous code is executing first and asynchronous code is running background.
a glimpse of my code:
When(/^I select the required "(.*?)" collection "(.*?)" from Select Collection Modal Window "(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","(.*?)"$/,(collection_type,collection_name,level,tag,level1,tag1,level2,tag2)=>{
bid_config.click_Tag_Assignment();
bid_config.click_Select_Collections();
expect(bid_config.select_Collection_modal_window.isDisplayed()).to.be.eventually.true;
bid_config.Select_Collection(collection_type,collection_name);
//bid_config.Select_Bid_Collection(collection_name);
bid_config.get_Entity_type_Drop_down_Text('H9 - Commodity/Entity');
bid_config.AssignTags_to_WBS_Levels(level,tag,level1,tag1,level2,tag2);
})
my problem is get_Entity_type_Drop_Down_text() is executing first and the select_Collections function() is processing in background
the code both the functions:
Select_Collection(collection_type,name){
var Collection_names = ;
var Collection_type_names = ;
(async()=>{
var get_collections_count = await this.get_collections_count();
for(var i=0;i<get_collections_count;i++){
Collection_names[i] = await this.Get_Collection_name(i);
console.log("the collection name is "+Collection_names[i]);
Collection_type_names[i] = await this.get_Collections_type(i);
console.log("the collection type is "+ Collection_type_names[i]);
if((collection_type === Collection_type_names[i]) && (Collection_names[i] === name)){
var click_Checkbox = element.all(by.xpath("//*[@class='ReactVirtualized__Table__rowColumn list-body-cell '][1]//*[@class='csc-checkbox-element']")).get(i);
click_Checkbox.click();
var click_add_collection_arrow = element.all(by.xpath("//*[@class='separator transfer-block']//button[@class='btn btn-success btn-sm']")).get(0);
//helper.waitForbuttonElement(click_add_collection_arrow);
browser.actions().click(click_add_collection_arrow).perform();
//click_add_collection_arrow.click();
var OK = element(by.xpath("//button[@class='btn btn-success' and @type = 'button']"));
browser.actions().click(OK).perform();
return browser.sleep(1000);
//return OK.click();
}
}
})();
}
get_Entity_type_Drop_down_Text(req_level){
element(by.xpath("//button[@class='btn btn-link dropdown-toggle']")).getText().then((text)=>{
console.log(text);
if(text === 'Commodities'){
let clickexpandDetails = element(by.xpath("//*[text()='Expand Details']"));
//helper.waitForbuttonElement(clickexpandDetails);
clickexpandDetails.click();
//H9 - Commodity/Entity']
let xpath_level = "//*[@class='dropdown-menu']//li[text()='"+req_level+"']";
let select_level = element(by.xpath(xpath_level));
//helper.waitForbuttonElement(select_level);
return browser.actions().click(select_level).perform();
}
})
}
please give me some suggestions to wait the synchronous code before the asynchronous code executes
javascript protractor cucumber
add a comment |
up vote
0
down vote
favorite
I am using JavaScript for my protractor cucumber framework.the synchronous code is executing first and asynchronous code is running background.
a glimpse of my code:
When(/^I select the required "(.*?)" collection "(.*?)" from Select Collection Modal Window "(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","(.*?)"$/,(collection_type,collection_name,level,tag,level1,tag1,level2,tag2)=>{
bid_config.click_Tag_Assignment();
bid_config.click_Select_Collections();
expect(bid_config.select_Collection_modal_window.isDisplayed()).to.be.eventually.true;
bid_config.Select_Collection(collection_type,collection_name);
//bid_config.Select_Bid_Collection(collection_name);
bid_config.get_Entity_type_Drop_down_Text('H9 - Commodity/Entity');
bid_config.AssignTags_to_WBS_Levels(level,tag,level1,tag1,level2,tag2);
})
my problem is get_Entity_type_Drop_Down_text() is executing first and the select_Collections function() is processing in background
the code both the functions:
Select_Collection(collection_type,name){
var Collection_names = ;
var Collection_type_names = ;
(async()=>{
var get_collections_count = await this.get_collections_count();
for(var i=0;i<get_collections_count;i++){
Collection_names[i] = await this.Get_Collection_name(i);
console.log("the collection name is "+Collection_names[i]);
Collection_type_names[i] = await this.get_Collections_type(i);
console.log("the collection type is "+ Collection_type_names[i]);
if((collection_type === Collection_type_names[i]) && (Collection_names[i] === name)){
var click_Checkbox = element.all(by.xpath("//*[@class='ReactVirtualized__Table__rowColumn list-body-cell '][1]//*[@class='csc-checkbox-element']")).get(i);
click_Checkbox.click();
var click_add_collection_arrow = element.all(by.xpath("//*[@class='separator transfer-block']//button[@class='btn btn-success btn-sm']")).get(0);
//helper.waitForbuttonElement(click_add_collection_arrow);
browser.actions().click(click_add_collection_arrow).perform();
//click_add_collection_arrow.click();
var OK = element(by.xpath("//button[@class='btn btn-success' and @type = 'button']"));
browser.actions().click(OK).perform();
return browser.sleep(1000);
//return OK.click();
}
}
})();
}
get_Entity_type_Drop_down_Text(req_level){
element(by.xpath("//button[@class='btn btn-link dropdown-toggle']")).getText().then((text)=>{
console.log(text);
if(text === 'Commodities'){
let clickexpandDetails = element(by.xpath("//*[text()='Expand Details']"));
//helper.waitForbuttonElement(clickexpandDetails);
clickexpandDetails.click();
//H9 - Commodity/Entity']
let xpath_level = "//*[@class='dropdown-menu']//li[text()='"+req_level+"']";
let select_level = element(by.xpath(xpath_level));
//helper.waitForbuttonElement(select_level);
return browser.actions().click(select_level).perform();
}
})
}
please give me some suggestions to wait the synchronous code before the asynchronous code executes
javascript protractor cucumber
My suggestion for you to rewrite everything you have to async functions. I've been struggling with this for a while, and had to redo to get rig of the problem and don't regret of time spent for this
– Sergey Pleshakov
5 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using JavaScript for my protractor cucumber framework.the synchronous code is executing first and asynchronous code is running background.
a glimpse of my code:
When(/^I select the required "(.*?)" collection "(.*?)" from Select Collection Modal Window "(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","(.*?)"$/,(collection_type,collection_name,level,tag,level1,tag1,level2,tag2)=>{
bid_config.click_Tag_Assignment();
bid_config.click_Select_Collections();
expect(bid_config.select_Collection_modal_window.isDisplayed()).to.be.eventually.true;
bid_config.Select_Collection(collection_type,collection_name);
//bid_config.Select_Bid_Collection(collection_name);
bid_config.get_Entity_type_Drop_down_Text('H9 - Commodity/Entity');
bid_config.AssignTags_to_WBS_Levels(level,tag,level1,tag1,level2,tag2);
})
my problem is get_Entity_type_Drop_Down_text() is executing first and the select_Collections function() is processing in background
the code both the functions:
Select_Collection(collection_type,name){
var Collection_names = ;
var Collection_type_names = ;
(async()=>{
var get_collections_count = await this.get_collections_count();
for(var i=0;i<get_collections_count;i++){
Collection_names[i] = await this.Get_Collection_name(i);
console.log("the collection name is "+Collection_names[i]);
Collection_type_names[i] = await this.get_Collections_type(i);
console.log("the collection type is "+ Collection_type_names[i]);
if((collection_type === Collection_type_names[i]) && (Collection_names[i] === name)){
var click_Checkbox = element.all(by.xpath("//*[@class='ReactVirtualized__Table__rowColumn list-body-cell '][1]//*[@class='csc-checkbox-element']")).get(i);
click_Checkbox.click();
var click_add_collection_arrow = element.all(by.xpath("//*[@class='separator transfer-block']//button[@class='btn btn-success btn-sm']")).get(0);
//helper.waitForbuttonElement(click_add_collection_arrow);
browser.actions().click(click_add_collection_arrow).perform();
//click_add_collection_arrow.click();
var OK = element(by.xpath("//button[@class='btn btn-success' and @type = 'button']"));
browser.actions().click(OK).perform();
return browser.sleep(1000);
//return OK.click();
}
}
})();
}
get_Entity_type_Drop_down_Text(req_level){
element(by.xpath("//button[@class='btn btn-link dropdown-toggle']")).getText().then((text)=>{
console.log(text);
if(text === 'Commodities'){
let clickexpandDetails = element(by.xpath("//*[text()='Expand Details']"));
//helper.waitForbuttonElement(clickexpandDetails);
clickexpandDetails.click();
//H9 - Commodity/Entity']
let xpath_level = "//*[@class='dropdown-menu']//li[text()='"+req_level+"']";
let select_level = element(by.xpath(xpath_level));
//helper.waitForbuttonElement(select_level);
return browser.actions().click(select_level).perform();
}
})
}
please give me some suggestions to wait the synchronous code before the asynchronous code executes
javascript protractor cucumber
I am using JavaScript for my protractor cucumber framework.the synchronous code is executing first and asynchronous code is running background.
a glimpse of my code:
When(/^I select the required "(.*?)" collection "(.*?)" from Select Collection Modal Window "(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","(.*?)"$/,(collection_type,collection_name,level,tag,level1,tag1,level2,tag2)=>{
bid_config.click_Tag_Assignment();
bid_config.click_Select_Collections();
expect(bid_config.select_Collection_modal_window.isDisplayed()).to.be.eventually.true;
bid_config.Select_Collection(collection_type,collection_name);
//bid_config.Select_Bid_Collection(collection_name);
bid_config.get_Entity_type_Drop_down_Text('H9 - Commodity/Entity');
bid_config.AssignTags_to_WBS_Levels(level,tag,level1,tag1,level2,tag2);
})
my problem is get_Entity_type_Drop_Down_text() is executing first and the select_Collections function() is processing in background
the code both the functions:
Select_Collection(collection_type,name){
var Collection_names = ;
var Collection_type_names = ;
(async()=>{
var get_collections_count = await this.get_collections_count();
for(var i=0;i<get_collections_count;i++){
Collection_names[i] = await this.Get_Collection_name(i);
console.log("the collection name is "+Collection_names[i]);
Collection_type_names[i] = await this.get_Collections_type(i);
console.log("the collection type is "+ Collection_type_names[i]);
if((collection_type === Collection_type_names[i]) && (Collection_names[i] === name)){
var click_Checkbox = element.all(by.xpath("//*[@class='ReactVirtualized__Table__rowColumn list-body-cell '][1]//*[@class='csc-checkbox-element']")).get(i);
click_Checkbox.click();
var click_add_collection_arrow = element.all(by.xpath("//*[@class='separator transfer-block']//button[@class='btn btn-success btn-sm']")).get(0);
//helper.waitForbuttonElement(click_add_collection_arrow);
browser.actions().click(click_add_collection_arrow).perform();
//click_add_collection_arrow.click();
var OK = element(by.xpath("//button[@class='btn btn-success' and @type = 'button']"));
browser.actions().click(OK).perform();
return browser.sleep(1000);
//return OK.click();
}
}
})();
}
get_Entity_type_Drop_down_Text(req_level){
element(by.xpath("//button[@class='btn btn-link dropdown-toggle']")).getText().then((text)=>{
console.log(text);
if(text === 'Commodities'){
let clickexpandDetails = element(by.xpath("//*[text()='Expand Details']"));
//helper.waitForbuttonElement(clickexpandDetails);
clickexpandDetails.click();
//H9 - Commodity/Entity']
let xpath_level = "//*[@class='dropdown-menu']//li[text()='"+req_level+"']";
let select_level = element(by.xpath(xpath_level));
//helper.waitForbuttonElement(select_level);
return browser.actions().click(select_level).perform();
}
})
}
please give me some suggestions to wait the synchronous code before the asynchronous code executes
javascript protractor cucumber
javascript protractor cucumber
asked 15 hours ago
vuppuluri atchyutha rama dixit
92
92
My suggestion for you to rewrite everything you have to async functions. I've been struggling with this for a while, and had to redo to get rig of the problem and don't regret of time spent for this
– Sergey Pleshakov
5 hours ago
add a comment |
My suggestion for you to rewrite everything you have to async functions. I've been struggling with this for a while, and had to redo to get rig of the problem and don't regret of time spent for this
– Sergey Pleshakov
5 hours ago
My suggestion for you to rewrite everything you have to async functions. I've been struggling with this for a while, and had to redo to get rig of the problem and don't regret of time spent for this
– Sergey Pleshakov
5 hours ago
My suggestion for you to rewrite everything you have to async functions. I've been struggling with this for a while, and had to redo to get rig of the problem and don't regret of time spent for this
– Sergey Pleshakov
5 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371924%2fi-am-unable-to-use-synchronous-functions-and-asynchronous-functions-of-javascrip%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
My suggestion for you to rewrite everything you have to async functions. I've been struggling with this for a while, and had to redo to get rig of the problem and don't regret of time spent for this
– Sergey Pleshakov
5 hours ago