Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Examples/browser-management/attribute.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
*** Settings ***
Library PuppeteerLibrary
Suite Teardown Close Puppeteer
Test Teardown Close All Browser

*** Variables ***
${DEFAULT_BROWSER} chrome


*** Test Cases ***
Get page title
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
${HEADLESS} = Get variable value ${HEADLESS} ${False}
&{options} = create dictionary headless=${HEADLESS}
Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} options=${options}
${title} = Get Title
Should Be Equal As Strings Basic HTML Elements ${title}

Get url
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
${HEADLESS} = Get variable value ${HEADLESS} ${False}
&{options} = create dictionary headless=${HEADLESS}
Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} options=${options}
${url} = Get Location
Should Contain ${url} basic-html-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Test Teardown Close All Browser

*** Test Cases ***
Webkit new page cause exception require ignore waiting
[Tags] Ignore_chrome Ignore_pwchrome Ignore_firefox
[Tags] Ignore_chrome Ignore_pwchrome Ignore_firefox Ignore_ptchrome
${BROWSER} = Get variable value ${BROWSER} webkit
${HEADLESS} = Get variable value ${HEADLESS} ${False}
&{options} = create dictionary headless=${HEADLESS}
Expand Down
6 changes: 2 additions & 4 deletions PuppeteerLibrary/keywords/browsermanagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ def close_puppeteer(self):
@keyword
def get_title(self):
"""Get page title"""
async def get_title_async():
return await self.ctx.get_current_page().title()
return self.loop.run_until_complete(get_title_async())
return self.loop.run_until_complete(self.ctx.get_current_library_context().get_current_page().title())

@keyword
def get_location(self):
"""Get page location"""
return self.ctx.get_current_page().url
return self.ctx.get_current_library_context().get_current_page().get_page().url

@keyword
def go_back(self):
Expand Down
12 changes: 9 additions & 3 deletions PuppeteerLibrary/playwright/custom_elements/playwright_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ async def click_with_selenium_locator(self, selenium_locator: str, options: dict
async def type_with_selenium_locator(self, selenium_locator: str, text: str, options: dict = None, **kwargs: Any):
selector_value = SelectorAbstraction.get_selector(selenium_locator)
if options is None:
options = {}
options = { 'state': 'visible' }
if self.selected_iframe is not None:
return await self.selected_iframe.type(selector=selector_value, text=text, **options)
await self.selected_iframe.wait_for_selector(selector=selector_value, **options)
return await self.selected_iframe.type(selector=selector_value, text=text)
else:
return await self.page.type(selector=selector_value, text=text, **options)
await self.page.wait_for_selector(selector=selector_value, **options)
return await self.page.type(selector=selector_value, text=text)

############
# Wait
Expand Down Expand Up @@ -95,15 +97,19 @@ async def waitForSelector_with_selenium_locator(self, selenium_locator: str, tim
async def querySelectorAll_with_selenium_locator(self, selenium_locator: str):
selector_value = SelectorAbstraction.get_selector(selenium_locator)
if self.selected_iframe is not None:
await self.selected_iframe.wait_for_selector(selector=selector_value)
return await self.selected_iframe.query_selector_all(selector_value)
else:
await self.get_page().wait_for_selector(selector=selector_value)
return await self.get_page().query_selector_all(selector_value)

async def querySelector_with_selenium_locator(self, selenium_locator: str):
selector_value = SelectorAbstraction.get_selector(selenium_locator)
if self.selected_iframe is not None:
await self.selected_iframe.wait_for_selector(selector=selector_value)
return await self.selected_iframe.query_selector(selector_value)
else:
await self.get_page().wait_for_selector(selector=selector_value)
return await self.get_page().query_selector(selector_value)

############
Expand Down