问题描述
我有一个电子应用程序,我正在使用 Spectron 编写集成测试。我的要求很简单——我有一个基于用户名/密码的登录,我想测试登录是否有效。
我已设法自动填充用户名和密码并单击登录按钮。一切正常,我会自动重定向到新页面。但是如何在玩笑中测试这个?具体如下:
const newPageText = await app.client.$('some-text-id');
expect(newPageText).toEqual('You have been successfully logged in');
编辑:我能够通过 hack 解决问题
export const delay = (time: number) => new Promise(resolve => setTimeout(resolve,time));
await delay(5000);
const url = await app.client.getUrl();
expect(url).toMatch('http://expected-new-url');
但是如果我做一个
await app.client.waitUntilWindowLoaded();
const url = await app.client.getUrl();
expect(url).toMatch('http://expected-new-url');
它不起作用。我得到一个
waitUntilWindowLoaded waitUntil condition Failed with the following reason: javascript error: window[requireName] is not a function
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)