selene icon indicating copy to clipboard operation
selene copied to clipboard

How to check if browser is open or exit

Open braunman opened this issue 4 years ago • 2 comments

No way, to understand if browser was use and now open.

braunman avatar Nov 05 '21 13:11 braunman

Seems like in Selene there is no specific method for that. So you can check this same way as you would do with raw selenium webdriver. As I remember, we usually just check if we can get a title frombrowser.driver

yashaka avatar Feb 20 '22 13:02 yashaka

@braunman I have left some thoughts on the topic under #402. Check them for some snippets, like


def is_browser_opened(browser):
    try:
        return browser.driver.title is not None
    except Exception:
        return None

# and then use it like:
if browser.get(is_browser_opened):
    # do something safely here...
    ...

yashaka avatar Feb 20 '22 13:02 yashaka