From b6df94ea03db4fec58dfdfdf24cae7005f4ef5d6 Mon Sep 17 00:00:00 2001 From: atthaboons Date: Wed, 31 Mar 2021 18:38:10 +0700 Subject: [PATCH 1/6] Fix open browser support option as None --- Examples/browser-management/open-close-browser.robot | 4 ++++ PuppeteerLibrary/keywords/browsermanagement.py | 2 +- PuppeteerLibrary/library_context/ilibrary_context.py | 4 ++-- PuppeteerLibrary/playwright/playwright_context.py | 4 ++-- PuppeteerLibrary/puppeteer/puppeteer_context.py | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Examples/browser-management/open-close-browser.robot b/Examples/browser-management/open-close-browser.robot index 4af9152..450c6fe 100644 --- a/Examples/browser-management/open-close-browser.robot +++ b/Examples/browser-management/open-close-browser.robot @@ -9,6 +9,10 @@ ${DEFAULT_BROWSER} chrome *** Test Cases *** +Open browser without option + ${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER} + Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} + Switch to new browser ${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER} ${HEADLESS} = Get variable value ${HEADLESS} ${False} diff --git a/PuppeteerLibrary/keywords/browsermanagement.py b/PuppeteerLibrary/keywords/browsermanagement.py index 66b5bff..8262185 100644 --- a/PuppeteerLibrary/keywords/browsermanagement.py +++ b/PuppeteerLibrary/keywords/browsermanagement.py @@ -12,7 +12,7 @@ def get_async_keyword_group(self) -> iBrowserManagementAsync: return self.ctx.get_current_library_context().get_async_keyword_group(type(self).__name__) @keyword - def open_browser(self, url, browser="chrome", alias=None, options=None): + def open_browser(self, url, browser="chrome", alias=None, options={}): """Opens a new browser instance to the specific ``url``. The ``browser`` argument specifies which browser to use. diff --git a/PuppeteerLibrary/library_context/ilibrary_context.py b/PuppeteerLibrary/library_context/ilibrary_context.py index 8745aa8..96c6dff 100644 --- a/PuppeteerLibrary/library_context/ilibrary_context.py +++ b/PuppeteerLibrary/library_context/ilibrary_context.py @@ -14,7 +14,7 @@ def __init__(self, browser_type: str): self.screenshot_path = os.curdir @abstractmethod - async def start_server(self, options: dict=None): + async def start_server(self, options: dict={}): pass @abstractmethod @@ -26,7 +26,7 @@ def is_server_started(self) -> bool: pass @abstractmethod - async def create_new_page(self, options: dict=None) -> BasePage: + async def create_new_page(self, options: dict={}) -> BasePage: pass @abstractmethod diff --git a/PuppeteerLibrary/playwright/playwright_context.py b/PuppeteerLibrary/playwright/playwright_context.py index 5ea74d5..3ed6795 100644 --- a/PuppeteerLibrary/playwright/playwright_context.py +++ b/PuppeteerLibrary/playwright/playwright_context.py @@ -33,7 +33,7 @@ class PlaywrightContext(iLibraryContext): def __init__(self, browser_type: str): super().__init__(browser_type) - async def start_server(self, options: dict=None): + async def start_server(self, options: dict={}): default_options = { 'slowMo': 0, 'headless': True, @@ -67,7 +67,7 @@ def is_server_started(self) -> bool: return True return False - async def create_new_page(self, options: dict=None) -> BasePage: + async def create_new_page(self, options: dict={}) -> BasePage: device_options = { 'accept_downloads': True } diff --git a/PuppeteerLibrary/puppeteer/puppeteer_context.py b/PuppeteerLibrary/puppeteer/puppeteer_context.py index 45f847b..2a5e68c 100644 --- a/PuppeteerLibrary/puppeteer/puppeteer_context.py +++ b/PuppeteerLibrary/puppeteer/puppeteer_context.py @@ -35,7 +35,7 @@ class PuppeteerContext(iLibraryContext): def __init__(self, browser_type: str): super().__init__(browser_type) - async def start_server(self, options: dict=None): + async def start_server(self, options: dict={}): default_args = [] default_options = { 'slowMo': 0, @@ -74,7 +74,7 @@ def is_server_started(self) -> bool: return True return False - async def create_new_page(self, options: dict=None) -> BasePage: + async def create_new_page(self, options: dict={}) -> BasePage: new_page = await self.browser.newPage() self.current_page = PuppeteerPage(new_page) if 'emulate' in options: From 34396b616c313addf6d13979c1f9e2f6d9fecf10 Mon Sep 17 00:00:00 2001 From: atthaboons Date: Wed, 31 Mar 2021 18:50:56 +0700 Subject: [PATCH 2/6] Add demo other options --- .../browser-management/open-close-browser.robot | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Examples/browser-management/open-close-browser.robot b/Examples/browser-management/open-close-browser.robot index 450c6fe..fa53138 100644 --- a/Examples/browser-management/open-close-browser.robot +++ b/Examples/browser-management/open-close-browser.robot @@ -5,14 +5,23 @@ Test Teardown Close All Browser *** Variables *** -${DEFAULT_BROWSER} chrome +${DEFAULT_BROWSER} pwchrome *** Test Cases *** Open browser without option ${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER} Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} - + +Ignore https error + ${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER} + ${HEADLESS} = Get variable value ${HEADLESS} ${False} + &{options} = create dictionary + ... headless=${HEADLESS} + ... ignore_https_errors=${True} + ... ignoreHTTPSErrors=${True} + Open browser https://http-password.badssl.com browser=${BROWSER} options=${options} + Switch to new browser ${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER} ${HEADLESS} = Get variable value ${HEADLESS} ${False} From a16099e746dfe3dbf420991d0ef29c6b49c5c229 Mon Sep 17 00:00:00 2001 From: atthaboons Date: Wed, 31 Mar 2021 18:52:46 +0700 Subject: [PATCH 3/6] Clean up code --- Examples/browser-management/open-close-browser.robot | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Examples/browser-management/open-close-browser.robot b/Examples/browser-management/open-close-browser.robot index fa53138..836b686 100644 --- a/Examples/browser-management/open-close-browser.robot +++ b/Examples/browser-management/open-close-browser.robot @@ -13,15 +13,6 @@ Open browser without option ${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER} Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} -Ignore https error - ${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER} - ${HEADLESS} = Get variable value ${HEADLESS} ${False} - &{options} = create dictionary - ... headless=${HEADLESS} - ... ignore_https_errors=${True} - ... ignoreHTTPSErrors=${True} - Open browser https://http-password.badssl.com browser=${BROWSER} options=${options} - Switch to new browser ${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER} ${HEADLESS} = Get variable value ${HEADLESS} ${False} From b75fe3763820e967a1431c08be4aebfa2c92cf7b Mon Sep 17 00:00:00 2001 From: atthaboons Date: Wed, 31 Mar 2021 18:56:49 +0700 Subject: [PATCH 4/6] Update ubuntu lib version --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 9ae55c0..6169f69 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -49,7 +49,7 @@ jobs: libegl1 \ libnotify4 \ libxslt1.1 \ - libevent-2.1-6 \ + libevent-2.1-7 \ libgles2 \ libvpx5 \ libxcomposite1 \ From f4d08b037a8dc431e20f2ed18a20e0579484ebf7 Mon Sep 17 00:00:00 2001 From: atthaboons Date: Wed, 31 Mar 2021 18:58:40 +0700 Subject: [PATCH 5/6] Update libvpx to v6 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 6169f69..507933d 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -51,7 +51,7 @@ jobs: libxslt1.1 \ libevent-2.1-7 \ libgles2 \ - libvpx5 \ + libvpx6 \ libxcomposite1 \ libatk1.0-0 \ libatk-bridge2.0-0 \ From 801c9044295685e4279a287051db38a593013b9f Mon Sep 17 00:00:00 2001 From: atthaboons Date: Wed, 31 Mar 2021 19:02:18 +0700 Subject: [PATCH 6/6] Add missing lib --- .github/workflows/pythonpackage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 507933d..7b9ff22 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -57,6 +57,7 @@ jobs: libatk-bridge2.0-0 \ libepoxy0 \ libgtk-3-0 \ + libgstreamer-gl1.0-0 \ libharfbuzz-icu0 \ xvfb - name: Lint with flake8