I am working on angular app automation where I have written a common function which needs to called at multiple places in my tests to get the form id which is generating dynamically. This function is always returning me {[[PromiseStatus]]: "pending"}"] error.
CommonFunctions.js
var common_functions = function() {
this.getFormId = function() {
// var url = "http://localhost/test/#/submission/207/form/1976";
return browser.getCurrentUrl().then(function(url){
return url.substr(-4);
});
}
};
Now this function is being used in pageobject file to get the element locator.
PageObject file:
var general_information = function() {
this.street1 = function(field1) {
var formid = common_functions.getFormId();
var street="fieldValue.street1_".concat(formid);
element(by.model(street)).sendKeys(field1);
}
Finally when i invoke this function in my test script, I get error.
Test script:
it("Verify that user is able to fill values in general information", function(){
general_information.street1('Street Victoria');
general_information.zipCode('1004');
});
Exception appearing:
Failed: invalid element state: Failed to execute 'querySelectorAll' on 'Document': '[ng-model="fieldValue.street1_Promise::1833 {[[PromiseStatus]]: "pending"}"]' is not a valid selector.
(Session info: chrome=50.0.2661.94)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64)
Can somebody help me with this where I am doing it wrong?