This article is a mirror article of machine translation, please click here to jump to the original article.

View: 1228|Reply: 8

[Tips] 【Playwright】(2) Common functions and operations

[Copy link]
Posted on 2025-5-27 14:04:35 | | | |
Playwright Trace Viewer tool to track test execution:

The Playwright Trace Viewer tool records multiple traces (trace chunks):

Open the trace file locally:

Enable Playwright recording to automatically generate code scripts:

Common Operations:

Set the default directory for the playwright environment:

playwright simulates HTTP interface requests

Playwright gets cookies


Reference:The hyperlink login is visible.




Previous:[Playwright] (1) Playwright for .NET usage tutorial
Next:[Nexus3] (1) Deploy Nexus tutorial with Docker installation
 Landlord| Posted on 2025-5-27 16:49:08 |
Take a screenshot of the entire page

The hyperlink login is visible.
 Landlord| Posted on 2025-6-12 09:47:43 |
a tag timeout TimeoutException exception handling, the exception is as follows:
System.TimeoutException
  HResult=0x80131505
  Message=Timeout 30000ms exceeded.
Call log:
  - attempting click action
    2 × waiting for element to be visible, enabled and stable
      - element is visible, enabled and stable
      - scrolling into view if needed
      - done scrolling
      - <div tabindex="-1" role="dialog" aria-modal="true" class="modal fade show" id="staticBackdropLive" data-bs-keyboard="false" data-bs-backdrop="static" aria-labelledby="staticBackdropLiveLabel">…</div> from <main class="bd-main order-1">…</main> subtree intercepts pointer events
    - retrying click action
    - waiting 20ms
    2 × waiting for element to be visible, enabled and stable
      - element is visible, enabled and stable
      - scrolling into view if needed
      - done scrolling
      - <div tabindex="-1" role="dialog" aria-modal="true" class="modal fade show" id="staticBackdropLive" data-bs-keyboard="false" data-bs-backdrop="static" aria-labelledby="staticBackdropLiveLabel">…</div> from <main class="bd-main order-1">…</main> subtree intercepts pointer events
    - retrying click action
      - waiting 100ms
    57 × waiting for element to be visible, enabled and stable
       - element is visible, enabled and stable
       - scrolling into view if needed
       - done scrolling
       - <div tabindex="-1" role="dialog" aria-modal="true" class="modal fade show" id="staticBackdropLive" data-bs-keyboard="false" data-bs-backdrop="static" aria-labelledby="staticBackdropLiveLabel">…</div> from <main class="bd-main order-1">…</main> subtree intercepts pointer events
     - retrying click action
       - waiting 500ms
  Source=Microsoft.Playwright
  StackTrace:
   at Microsoft.Playwright.Transport.Connection. <InnerSendMessageToServerAsync>d__40'1.MoveNext() in /_/src/Playwright/Transport/Connection.cs: line 228
   at Microsoft.Playwright.Transport.Connection. <WrapApiCallAsync>d__52'1.MoveNext() in /_/src/Playwright/Transport/Connection.cs: line 541
   Use the ConsoleApp4.PlaywrightDemo. <Main>d__0.MoveNext() in D:\Project\ConsoleApp1\ConsoleApp4\PlaywrightDemo.cs: line 71
   Use the ConsoleApp4.PlaywrightDemo. <Main>d__0.MoveNext() in D:\Project\ConsoleApp1\ConsoleApp4\PlaywrightDemo.cs: line 83
   Use the ConsoleApp4.PlaywrightDemo. <Main>(String[] args)

Code:

Solution 1:

Solution 2 (recommended):
 Landlord| Posted on 2025-6-18 15:13:51 |
C# Moving Slider Captcha with Playwright (No Identification)

The code is as follows:

 Landlord| Posted on 2025-6-27 15:03:04 |
c# Use Playwright to customize the User-Agent identity
 Landlord| Posted on 2025-7-7 13:15:44 |
c# Use Playwright to call GotoAsync to access the web page to determine if there are 301 or 302 redirects
If there is a redirect, it proves that the authentication is invalid when visiting the link!

Reference:The hyperlink login is visible.
 Landlord| Posted on 2025-7-10 17:40:58 |
Execute the js script

Reference:The hyperlink login is visible.
 Landlord| Posted on 2025-7-21 10:30:52 |
C# Use Playwright to check the input checkbox
 Landlord| Posted on 2025-9-12 14:56:20 |
Number of Bootstrap modal pop-ups
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com