当前位置:网站首页>Playwright recording

Playwright recording

2022-07-05 00:48:00 Dotnet cross platform

Preface

Some time ago, I saw what the boss shared about Playwright.NET The article feels very interesting , Want to read Click : here , Then follow the steps of the boss , Learned a little Automation play , One of the recording functions feels very interesting , Now let's have a brief look

Introduce

Manually operate the browser , Will record our operation , And then generate the script .

operation

Create project

-- Create a console ( This is something to be aware of , The latest version will be installed directly )
 dotnet new console -n PlaywrightDemo
 --  Entry directory 
 cd PlaywrightDemo
 --  Generating project 
 dotnet build

 --  Add dependency package 
 dotnet add package Microsoft.Playwright

Install the necessary browser ( there netx Is the version of your current project )

pwsh bin\Debug\netX\playwright.ps1 install

--  Example 
pwsh bin\Debug\net7.0\playwright.ps1 install

Start recording

pwsh bin\Debug\netX\playwright.ps1 codegen

--  Example 
pwsh bin\Debug\net7.0\playwright.ps1 codegen

Then a browser and a window will open , Click on the browser to view another Playwright Inspector The generated code

b02274b74a6604dad190db9054283ca6.png
img

Be careful : Although it is convenient to generate code ( Simple or ok ), But the generated content needs careful observation , Some need secondary changes .

If you prompt an error 【 Cannot be “pwsh” Item identified as cmdlet、 function 、 The name of the script file or runnable program 】, So you need to upgrade PowerShell

dotnet tool update --global PowerShell

Information

file :https://playwright.dev/dotnet/docs/intro

原网站

版权声明
本文为[Dotnet cross platform]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050037465257.html