
在上面,您可以看到带有#account_email选择器的输入元素。但是,等待在此字段中选择和键入的jest功能测试每次都会失败。我不明白为什么。
下面有没有语法错误?这种类型的选择容易出错吗?任何关于解决这个问题的建议都是欢迎的。
// A functonal test file being run by jest.js
// jest-puppeteer
test('[functional] log into shopify"', async () => {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
// go to login page
await page.goto("https://partners.shopify.com/1185756/apps/3207477/test", {waitUntil : "load"});
console.log(page.url, `=====arrived at shopify login screen=====`);
// fill and submit form
const emailInput = await page.focus("#account_email");
await emailInput.type(process.env.SHOPIFY_PARTNER_EMAIL);// error seen in terminal
TypeError: Cannot read property 'type' of undefined
22 | // email screen
23 | const emailInput = await page.focus("#account_email");
> 24 | await emailInput.type(process.env.SHOPIFY_PARTNER_EMAIL);
| ^
25 |
// 发布于 2020-02-05 01:02:19
focus不返回元素句柄。你可以这样做:
const emailInput = await page.waitForSelector("#account_email");
await emailInput.focus();
await emailInput.type(process.env.SHOPIFY_PARTNER_EMAIL);https://stackoverflow.com/questions/60058784
复制相似问题