Interface PageAssertions

  • All Known Implementing Classes:
    PageAssertionsImpl

    public interface PageAssertions
    The PageAssertions class provides assertion methods that can be used to make assertions about the Page state in the tests.
    {@code
     ...
     import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
    
     public class TestPage {
       ...
    • Method Detail

      • not

        PageAssertions not()
        Makes the assertion check for the opposite condition. For example, this code tests that the page URL doesn't contain "error":
        
         assertThat(page).not().hasURL("error");
         
        Since:
        v1.20
      • hasTitle

        default void hasTitle​(java.lang.String titleOrRegExp)
        Ensures the page has the given title.

        **Usage**

        
         assertThat(page).hasTitle("Playwright");
         
        Parameters:
        titleOrRegExp - Expected title or RegExp.
        Since:
        v1.20
      • hasTitle

        void hasTitle​(java.lang.String titleOrRegExp,
                      PageAssertions.HasTitleOptions options)
        Ensures the page has the given title.

        **Usage**

        
         assertThat(page).hasTitle("Playwright");
         
        Parameters:
        titleOrRegExp - Expected title or RegExp.
        Since:
        v1.20
      • hasTitle

        default void hasTitle​(java.util.regex.Pattern titleOrRegExp)
        Ensures the page has the given title.

        **Usage**

        
         assertThat(page).hasTitle("Playwright");
         
        Parameters:
        titleOrRegExp - Expected title or RegExp.
        Since:
        v1.20
      • hasTitle

        void hasTitle​(java.util.regex.Pattern titleOrRegExp,
                      PageAssertions.HasTitleOptions options)
        Ensures the page has the given title.

        **Usage**

        
         assertThat(page).hasTitle("Playwright");
         
        Parameters:
        titleOrRegExp - Expected title or RegExp.
        Since:
        v1.20
      • hasURL

        default void hasURL​(java.lang.String urlOrRegExp)
        Ensures the page is navigated to the given URL.

        **Usage**

        
         assertThat(page).hasURL(".com");
         
        Parameters:
        urlOrRegExp - Expected URL string or RegExp.
        Since:
        v1.20
      • hasURL

        void hasURL​(java.lang.String urlOrRegExp,
                    PageAssertions.HasURLOptions options)
        Ensures the page is navigated to the given URL.

        **Usage**

        
         assertThat(page).hasURL(".com");
         
        Parameters:
        urlOrRegExp - Expected URL string or RegExp.
        Since:
        v1.20
      • hasURL

        default void hasURL​(java.util.regex.Pattern urlOrRegExp)
        Ensures the page is navigated to the given URL.

        **Usage**

        
         assertThat(page).hasURL(".com");
         
        Parameters:
        urlOrRegExp - Expected URL string or RegExp.
        Since:
        v1.20
      • hasURL

        void hasURL​(java.util.regex.Pattern urlOrRegExp,
                    PageAssertions.HasURLOptions options)
        Ensures the page is navigated to the given URL.

        **Usage**

        
         assertThat(page).hasURL(".com");
         
        Parameters:
        urlOrRegExp - Expected URL string or RegExp.
        Since:
        v1.20