Search code examples
pythonautomationplaywright-python

Printing results in playwright python eg. print(result)


I just learnt playwright python and wanted to know how one can print the results of a page to the terminal. I have tried printing to the terminal in the playwright function but it does nothing. Also how do you check if an element is in the DOM and return true or false?

this is what i am trying to do in pseudo-code.

if( this selector is on the page ){
    print("selector on page")
}

Solution

  • import logging
    LOGGER = logging.getLogger(__name__)
    
    if page.locator('Your Locator CSS/Xpath').is_visible():
        LOGGER.info('selector on page')