![]() One of the most usual problems with pages that contain a lot of content, because of the ads, images etc. There are many more classes and methods with Puppeteer, and a full list can be found here.During the automation of multiple tasks on my job and personal projects, i decided to move on Puppeteer instead of the old school PhantomJS. Separating the selectors and methods adds to further readability and makes the tests easier to maintain. ![]() We are using CSS selectors and the innerText pageFunction to evaluate the selector and return its inner text. This allows us to use the method elementHandle.$eval(selector, pageFunction, rewritten as app.$eval(introSelector, el => el.innerText). In this example, we've created an elementHandle instance from our app page object. ![]() The Puppeteer API has classes with methods that allow us to interact with a page. If you want to skip this section and add this set-up to your current project, you can jump to Adding to an Existing Project. To see Puppeteer in action, let's take a look at a sample project. However, it offers much faster and less-flaky browser automation than Selenium-Webdriver. There are a couple of limitations – Puppeteer is JavaScript-only (it’s a node.js library), and currently limited to Chromium or Chrome (though at time of writing there is an experimental puppeteer-firefox package). It runs headless by default but can easily be configured to run in a browser. Developed by Google, Puppeteer controls Chromium or Chrome through a high-level API. Puppeteer is a powerful tool for UI automation. It uses Jest as a test runner, modern JavaScript features and the page object model, and shows how easy it is to get Puppeteer up and running. ![]() ![]() This project provides a simple way to add Puppeteer to a create-react-app generated app. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |