javascript - Not able to use browser.waitForAngular successfully after executing browser.executeScript in protractor -
only case code works. intention browser.waitforangular() after browser.executescript(script) has executed. why case b , case c not work i.e. test fails if use case b , case c??????? wrote code solve timing issues. writing valid/logical code in case b , case c :
let executescript = (script, retrycount = 1) => { console.log("executing javascript:" + script); return browser.waitforangular().then(_ => { return this.waitformyconditiontobeready(8000).then(_ => { return browser.executescript(script).then( _ => _ , error => { // pass through if there's no error, otherwise handle error if (error.name && (retrycount < 7)) { console.log("error: while executing executescript, retry count, retrying in 2 secs. ", error.name, retrycount); browser.sleep(2000); return executescript(script, ++retrycount); } throw error; }); }, error => { console.log("error: papo not ready", error.name); throw error; }); }, error => { console.log("error: waitforangular in executescript: ", error.name); throw error; }); }; module.exports.executescript = executescript;
case b: add {return browser.waitforangular();} successful callback.
let executescript = (script, retrycount = 1) => { console.log("executing javascript:" + script); return browser.waitforangular().then(_ => { return this.waitformyconditiontobeready(8000).then(_ => { return browser.executescript(script).then( _ => {return browser.waitforangular();} , error => { // pass through if there's no error, otherwise handle error if (error.name && (retrycount < 7)) { console.log("error: while executing executescript, retry count, retrying in 2 secs. ", error.name, retrycount); browser.sleep(2000); return executescript(script, ++retrycount); } throw error; }); }, error => { console.log("error: papo not ready", error.name); throw error; }); }, error => { console.log("error: waitforangular in executescript: ", error.name); throw error; }); }; module.exports.executescript = executescript;
case c: if add waitforangular in end final then().
let executescript = (script, retrycount = 1) => { console.log("executing javascript:" + script); return browser.waitforangular().then(_ => { return this.waitformyconditiontobeready(8000).then(_ => { return browser.executescript(script).then( _ => _ , error => { // pass through if there's no error, otherwise handle error if (error.name && (retrycount < 7)) { console.log("error: while executing executescript, retry count, retrying in 2 secs. ", error.name, retrycount); browser.sleep(2000); return executescript(script, ++retrycount); } throw error; }); }, error => { console.log("error: papo not ready", error.name); throw error; }); }, error => { console.log("error: waitforangular in executescript: ", error.name); throw error; }).then( _ => {return browser.waitforangular();}); }; module.exports.executescript = executescript;
Comments
Post a Comment