Checking for amount of found locators should work
def is_element_present(selector): if page.locator(selector).count == 0: // No elements were found by this selector returns False return True