简体   繁体   English

傀儡师与Selenium

[英]Puppeteer vs. Selenium

I am trying to parse banking website and I have the whole workflow recorded in Selenium and everything works.我正在尝试解析银行网站,并且我将整个工作流程记录在 Selenium 中,并且一切正常。 Due to inability to persist cookies between sessions while using Selenium Webdriver (Cookies cannot be loaded - "missing name exception") I moved to puppeteer.由于在使用 Selenium Webdriver 时无法在会话之间保留 cookies(无法加载 Cookie -“缺少名称异常”),我搬到了 puppeteer。 Line by line it went good until I got the following lines:一行一行地运行良好,直到我得到以下几行:

In selenium:在 selenium 中:

await driver.findElement(By.css(".buttons:nth-child(4)")).click()

and in puppeteer在木偶戏中

await page.frames()[1].click('.buttons:nth-child(4)');

does not work.不起作用。

What is funny though:不过有什么好笑的:

await page.frames()[1].waitForSelector('.buttons:nth-child(4)');

does not throw exception so element is present on the page.不会引发异常,因此页面上存在元素。

page.frames() will return a promise. page.frames() 将返回 promise。 You have to await almost everything:您必须等待几乎所有内容:

let frames = await page.frames()
await frames[1].click('.buttons:nth-child(4)');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM