I'm trying to pass a string value from my function editPage.CreateEntity();
, I need to use that value on most of my test cases under the variable entityName
, I'm able to get the value if I set the test case like this:
fit('Test Case', async () => {
await editEntityPage.CreateEntity("Automation Entity: ", "California").then(function(name){
console.log(name);
return entityName = name;
});
await entity.SearchAndClickEntity(entityName);
});
but how can I do it to get this value from the begining but NOT beforeEach()
test case
describe('Test Suite', () => {
var editPage = require('../pathtofile.js');
var entityName = editPage.CreateEntity("Automation Entity: ", "California").then(function(name){
return name;
});
console.log("Testing Start:");
console.log(entityName);
console.log(JSON.stringify(entityName));
beforeEach(async function(){
await browser.waitForAngularEnabled(false);
});
it('Test Case', async () => {
await entity.SearchAndClickEntity(entityName);
});
ps. when I try to get the value from the console.logs
I get this:
Testing Start:
Promise { <pending> }
{}