![]() It contains the captured screenshot of the page launched in the browser. const puppeteer require ( 'puppeteer' ) // were using async/await - so we need an async function, that we can run const run async. Lets create a screenshot of the codesnacks homepage. Automatically creating a screenshot of a webpage used to be hard. So in our example, we shall run the following command −Īfter the command has been successfully executed, a new file called the tutorialspoint.png gets created within the page directory. Create a screenshot of a webpage with Javascript. Step 4 − Execute the code with the command given below − Step 3 − Add the below code within the testcase1.js file created.Īwait p.setViewport() Step 2 − Enter a filename, say testcase1.js. ![]() Right-click on the folder where the node_modules folder is created, then click on the New file button. The details on Puppeteer installation is discussed in the Chapter of Puppeteer Installation. Step 1 − Create a new file within the directory where the node_modules folder is created (location where the Puppeteer and Puppeteer core have been installed). To begin, follow Steps 1 to 2 from the Chapter of Basic Test on Puppeteer which are as follows − Let us capture the screenshot of the below page − Path: 'tutorialspoint.png', fullPage: true To capture the full page screenshot, we have to pass another parameter called the fullPage and set its value to true. With this, only the viewable part of the web page shall be captured. Here, the path where the screenshot is to be saved is passed as a parameter to the method. The syntax to capture screenshot in Puppeteer is as follows − A screenshot is generally captured if we encounter an application error, a failure in a test case, and so on. ![]() ![]() We can capture screenshots while working on automation tests developed in Puppeteer using the screenshot method. Comparison Between Puppeteer & Protractor This can probably be a part of puppeteer.Comparison Between Puppeteer & Selenium. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |