Skip to content

Commit

Permalink
Fix issue open browser with none option (#104)
Browse files Browse the repository at this point in the history
* Fix open browser support option as None

* Add demo other options

* Clean up code

* Update ubuntu lib version

* Update libvpx to v6

* Add missing lib
  • Loading branch information
atthaboon authored Mar 31, 2021
1 parent 0b78346 commit 9be1959
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ jobs:
libegl1 \
libnotify4 \
libxslt1.1 \
libevent-2.1-6 \
libevent-2.1-7 \
libgles2 \
libvpx5 \
libvpx6 \
libxcomposite1 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libepoxy0 \
libgtk-3-0 \
libgstreamer-gl1.0-0 \
libharfbuzz-icu0 \
xvfb
- name: Lint with flake8
Expand Down
6 changes: 5 additions & 1 deletion Examples/browser-management/open-close-browser.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ 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}

Switch to new browser
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
${HEADLESS} = Get variable value ${HEADLESS} ${False}
Expand Down
2 changes: 1 addition & 1 deletion PuppeteerLibrary/keywords/browsermanagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions PuppeteerLibrary/library_context/ilibrary_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions PuppeteerLibrary/playwright/playwright_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions PuppeteerLibrary/puppeteer/puppeteer_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9be1959

Please sign in to comment.