1
我试图用木偶来测试角度的应用程序。但是当我尝试点击一个链接(不是路由到相应的视图)时它不起作用。使用puppeteer点击链接角度的应用程序不工作
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.goto('https://example.com', {waitUntil: 'networkidle'});
await page.focus('input[name="username"]');
await page.type('username');
await page.focus('input[name="password"]');
await page.type('password');
await page.click('button[type="submit"]');
await page.waitForNavigation({waitUntil: 'networkidle'});
// code below logs https://example.com
// actual url is https://example.com/#home
console.log(page.url())
const link = await page.$('a[href="#/other"]');
await link.click()
// code below logs https://example.com
// actual url is still https://example.com/#home
console.log(page.url())
点击链接后,感觉就像一个页面刷新,并再次进入相同的网址。 url
未发生变化可能是因为FrameNavigated
事件未从puppeteer发出。那么,如何等待角路由器完成和所有相应的ajax请求结束呢?