Header Ads

  • Breaking News

    Expect and Auto-waits in Playwright

    For any automation script, using the right assertions are very important. Playwright gives expect function which has many methods like oEqual, toContains, toHaveString, tobevisible, and others which makes assertions very simple and efficient. Using this method we can verify if the locator has the exact value we required, if the locator is visible, if the value I set id populated or not etc. This is the perfect way to find bugs using automation. 

    Another key functionality of the playwright is auto-waits. Auto-waits make sure that the elements or actions we are performing using automation gets completed. To do this it waits till the locator gets stable, visible, available in dom or not. It totally depends on the action we are going to perform. For example, for page.click(), Playwright will ensure that:
    • element is Attached to the DOM
    • element is Visible
    • element is Stable, as in not animating or completed animation
    • element Receives Events, as in not obscured by other elements
    • element is Enabled
    In other tools, you may have to do these manually. 

    I have created a video tutorial on the same with the code demo, please go through the below video and subscribe to our youtube channel. Here I have explained how this expect and auto-waits work in the playwright?

    In this video, I have explained 
    1. Assertions and Methods of Expect function 
    2. soft assertions - when to use soft assertions 
    3. Message - how to put a custom message with expect? 
    4. auto waiting - how auto-wait works in playwright?

    Here is the Playwright document 
    If you have any doubts or suggestions feel free to reach out on social media. Follow Us on RedditFacebook, and Twitter. Don't forget to subscribe to the channel -> Youtube channel. Thank You

    No comments

    Post Top Ad

    Post Bottom Ad