FAIL : Error: Tried to do playwright action, but no open page

BuiltIn().get_library_instance(“SeleniumLibrary”) is OK but BuiltIn().get_library_instance(“Browser”) can’t found? how to do that.

below code i can open browser success on playwright. but when click element, it failed to input element and told no browser open. I use BuiltIn().get_library_instance(“SeleniumLibrary”) to close selenium issue. but for playwright, it can’t find Browser.

CODE1:

coding=utf-8

from robot.libraries.BuiltIn import BuiltIn
from Browser.utils.data_types import SupportedBrowsers
from Factory import Factory
from Browser import Browser

class PlaywrightFactory(Factory):
# def init(self):
# self.pwlib = Browser(timeout=“20 s”, retry_assertions_for=“500 ms”)

def open(self, url, browser='chrome', headless:bool=False):
    '''
    |chrome  |Google Chrome, Microsoft Edge (since 2020), Opera |
    |firefox |Mozilla Firefox                                   |
    |webkit  |Apple Safari, Mail, AppStore on MacOS and iOS     |
    '''
    proxy = {"server": "http://XXXXXXXXXX"}
    if browser.lower()=='chrome':
        browser='chromium'
    else:
        browser=browser.lower()
    #self.browser = Browser.Browser(timeout=30)
    #self.pwlib = BuiltIn().get_library_instance("Browser")
    self.pwlib = Browser(timeout="30 s", retry_assertions_for="500 ms")
    self.pwlib.new_browser(browser=SupportedBrowsers[browser], headless=headless)
    self.pwlib.new_context(ignoreHTTPSErrors=True, proxy=proxy)
    self.pwlib.new_page(url)
    return "Playwright openbrowser"

def closebrowser(self):
    #self.browser = Browser.Browser()
    #self.pwlib = BuiltIn().get_library_instance("Browser")
    self.pwlib = Browser(timeout="30 s", retry_assertions_for="500 ms")
    self.pwlib.close_browser
    return "Playwright closebrowser"

def click(self, element):
    #self.browser = Browser.Browser()
    #self.pwlib = BuiltIn().get_library_instance("Browser")
    self.pwlib = Browser(timeout="30 s", retry_assertions_for="500 ms")
    self.pwlib.click(selector=element)
    return "Playwright play"

def type(self, element, value):
    #self.browser = Browser.Browser()
    #self.pwlib = BuiltIn().get_library_instance("Browser")
    self.pwlib = Browser(timeout="30 s", retry_assertions_for="500 ms")
    self.pwlib.type_text(selector=element, txt=value)
    return "Playwright type"

CODE2
*** Settings ***
Suite Setup setup chrome ${False}
Variables …/…/Resources/keywords/config.py ${env}
Library …/…/Resources/keywords/UI/Keywords.py ${platform}
Resource …/…/Resources/keywords/UI/business1.robot

*** Test Cases ***
Login_P
Login pXXX XXXX

LOG:
20210703 22:57:10.451 : INFO : {“browser”: “chromium”, “headless”: false, “handleSIGINT”: true, “handleSIGTERM”: true, “handleSIGHUP”: true, “timeout”: 30000.0, “devtools”: false, “slowMo”: 0.0, “tracesDir”: “/var/folders/cr/351t_m7j4xjcbm4jq531kyk1l0cm79/T/RIDE03nkanmq.d/browser/traces/6d618fdc-1a00-460f-81bf-cee8c1254afa”}
20210703 22:57:10.452 : INFO : Starting Browser process /usr/local/lib/python3.8/site-packages/Browser/wrapper/index.js using port 62233
20210703 22:57:21.628 : INFO : Successfully created browser with options: {“browser”:“chromium”,“headless”:false,“handleSIGINT”:true,“handleSIGTERM”:true,“handleSIGHUP”:true,“timeout”:30000,“devtools”:false,“slowMo”:0,“tracesDir”:"/var/folders/cr/351t_m7j4xjcbm4jq531kyk1l0cm79/T/RIDE03nkanmq.d/browser/traces/6d618fdc-1a00-460f-81bf-cee8c1254afa"}
20210703 22:57:21.629 : INFO : {“acceptDownloads”: false, “ignoreHTTPSErrors”: true, “bypassCSP”: false, “deviceScaleFactor”: 1.0, “isMobile”: false, “hasTouch”: false, “javaScriptEnabled”: true, “offline”: false, “proxy”: {“server”: “http://XXXXX”}, “hideRfBrowser”: false}
20210703 22:57:21.676 : INFO : Successfully created context.
20210703 22:57:21.676 : INFO : {‘acceptDownloads’: False, ‘ignoreHTTPSErrors’: True, ‘bypassCSP’: False, ‘deviceScaleFactor’: 1, ‘isMobile’: False, ‘hasTouch’: False, ‘javaScriptEnabled’: True, ‘offline’: False, ‘proxy’: {‘server’: ‘http://XXXXX’}, ‘hideRfBrowser’: False}
20210703 22:57:47.234 : INFO : Successfully initialized new page object and opened url: https://XXXXX
20210703 22:57:47.235 : INFO : {“acceptDownloads”:false,“ignoreHTTPSErrors”:true,“bypassCSP”:false,“deviceScaleFactor”:1,“isMobile”:false,“hasTouch”:false,“javaScriptEnabled”:true,“offline”:false,“proxy”:{“server”:“http://XXXXXX”},“hideRfBrowser”:false}
Starting test: Testframework.Tests.Ui.Test1.Login_P
20210703 22:57:47.277 : INFO : Types the text ‘productd@rakuten.com’ in the given field.
20210703 22:57:47.279 : INFO : Starting Browser process /usr/local/lib/python3.8/site-packages/Browser/wrapper/index.js using port 62366
20210703 22:57:47.617 : FAIL : Error: Tried to do playwright action, but no open page.