【发布时间】:2020-07-23 11:31:33
【问题描述】:
我正在尝试从我的函数editPage.CreateEntity(); 传递一个字符串值,我需要在变量entityName 下的大多数测试用例中使用该值,如果我设置像这样的测试用例:
fit('Test Case', async () => {
await editEntityPage.CreateEntity("Automation Entity: ", "California").then(function(name){
console.log(name);
return entityName = name;
});
await entity.SearchAndClickEntity(entityName);
});
但是我怎样才能从一开始就得到这个值但是 NOT beforeEach() 测试用例
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。当我尝试从console.logs 获取值时,我得到了这个:
Testing Start:
Promise { <pending> }
{}
【问题讨论】:
-
看看你是否可以在你的情况下使用
localStorage。以此为参考:stackoverflow.com/q/21960598/957026
标签: javascript selenium automation protractor