Skip to content

Commit

Permalink
Bump playwright from 0.171.1 to 1.9.0 (#95)
Browse files Browse the repository at this point in the history
* Bump playwright from 0.171.1 to 1.9.0

Bumps [playwright](https://github.com/Microsoft/playwright-python) from 0.171.1 to 1.9.0.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](microsoft/playwright-python@v0.171.1...v1.9.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Update playwirght function to 1.9.0 from snake case the underscore
  • Loading branch information
dependabot-preview[bot] authored Feb 26, 2021
1 parent 0fe79df commit c5c0f79
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 71 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ report.html
Examples/logs/
Examples/tmp-download/test.csv
Examples;tmp-download/test.csv
Examples/test.csv
4 changes: 2 additions & 2 deletions Examples/api/mock-api.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test Teardown Close All Browser
Suite Teardown Close Puppeteer

*** Variables ***
${DEFAULT_BROWSER} chrome
${DEFAULT_BROWSER} pwchrome
${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html


Expand All @@ -17,7 +17,7 @@ Mock ajax response with raw text
Wait Until Page Contains I'm a mock response text

Mock ajax response with json response
&{response} Create Dictionary body={ 'data': 'I\'m a mock response json'} contentType=application/json
&{response} Create Dictionary body={"data":"I\'m a mock response json"} content_type=application/json
Mock Current Page Api Response /ajax_info.json?count=3 ${response}
Click Element id=get_ajax
Wait Until Page Contains I'm a mock response json
Expand Down
9 changes: 5 additions & 4 deletions Examples/form-handler/download-file.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ Test Setup Open browser to test page
Test Teardown Close All Browser
Suite Teardown Close Puppeteer


*** Variables ***
${DEFAULT_BROWSER} chrome
${DEFAULT_BROWSER} pwchrome
${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html


*** Test Cases ***
Download file
Download file
${file path} = Download File id=download-file
Should Not Be Empty ${file path} Download file failed
Get File ${file path}
Wait Until Keyword Succeeds 3x 2s Copy File ${file path} test.csv
Get File test.csv

Upload file
${file} = OperatingSystem.Join Path ${CURDIR} iframe.robot
Expand Down
2 changes: 1 addition & 1 deletion Examples/form-handler/dropdown-list.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test Teardown Close All Browser
Suite Teardown Close Puppeteer

*** Variables ***
${DEFAULT_BROWSER} chrome
${DEFAULT_BROWSER} pwchrome
${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html


Expand Down
2 changes: 1 addition & 1 deletion Examples/utilities/generate-pdf.robot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Suite Teardown Close Puppeteer


*** Variables ***
${DEFAULT_BROWSER} firefox
${DEFAULT_BROWSER} pwchrome
${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html


Expand Down
2 changes: 1 addition & 1 deletion Examples/utilities/wait.robot
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Wait for http response
Wait for navigation
Open browser to test page ${HOME_PAGE_URL}
Run Async Keywords
... Wait For Navigation AND
... Wait For Navigation 2s AND
... Click Element id=goto-login-page

Wait for element hidden and visible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,28 @@ async def switch_window(self, locator='MAIN'):
pages = await self.library_ctx.get_all_pages()
if locator == 'MAIN':
page = pages[0]
await page.bringToFront()
await page.bring_to_front()
return self.library_ctx.set_current_page(page)

elif locator == 'NEW':
page = pages[-1]
await page.bringToFront()
await page.bring_to_front()
return self.library_ctx.set_current_page(page)

elif 'title=' in locator:
title = locator.replace('title=', '')
for page in pages:
page_title = await page.title()
if page_title == title:
await page.bringToFront()
await page.bring_to_front()
return self.library_ctx.set_current_page(page)
self.info('Title mismatch: ' + page_title)

elif 'url=' in locator:
url = locator.replace('url=', '')
for page in pages:
if re.match(url, page.url):
await page.bringToFront()
await page.bring_to_front()
return self.library_ctx.set_current_page(page)
self.info('Url mismatch: ' + page.url)
else:
Expand All @@ -84,7 +84,7 @@ async def switch_window(self, locator='MAIN'):
##############################
async def select_frame(self, locator: str):
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
iframe = await element.contentFrame()
iframe = await element.content_frame()
self.library_ctx.get_current_page().set_current_iframe(iframe)

def unselect_iframe(self):
Expand All @@ -106,11 +106,11 @@ async def get_cookies(self):

async def add_cookie(self, name: str, value: str):
url = self.library_ctx.get_current_page().get_page().url
await self.library_ctx.get_browser_context().contexts[0].addCookies([{
await self.library_ctx.get_browser_context().contexts[0].add_cookies([{
'url': url,
'name': name,
'value': value
}])

async def delete_all_cookies(self):
await self.library_ctx.get_browser_context().contexts[0].clearCookies()
await self.library_ctx.get_browser_context().contexts[0].clear_cookies()
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ async def checkbox_should_not_be_selected(self, locator):

async def is_checked(self, locator):
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
return (await (await element.getProperty('checked')).jsonValue())
return (await (await element.get_property('checked')).json_value())
24 changes: 10 additions & 14 deletions PuppeteerLibrary/playwright/async_keywords/playwright_dropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,40 @@ def __init__(self, library_ctx):

async def select_from_list_by_value(self, locator, values):
selector_value = SelectorAbstraction.get_selector(locator)
return await self.library_ctx.get_current_page().get_selected_frame_or_page().selectOption(selector_value, {
'value': values
})
return await self.library_ctx.get_current_page().get_selected_frame_or_page().select_option(selector_value, value=values)

async def select_from_list_by_label(self, locator, labels):
selector_value = SelectorAbstraction.get_selector(locator)
return await self.library_ctx.get_current_page().get_selected_frame_or_page().selectOption(selector_value, {
'label': labels
})
return await self.library_ctx.get_current_page().get_selected_frame_or_page().select_option(selector_value, label=labels)

async def get_selected_list_labels(self, locator: str) -> str:
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
options = await element.querySelectorAll('option:checked')
options = await element.query_selector_all('option:checked')
selected_labels = []
for option in options:
selected_labels.append((await (await option.getProperty('textContent')).jsonValue()))
selected_labels.append((await (await option.get_property('textContent')).json_value()))
return selected_labels

async def get_list_labels(self, locator: str) -> str:
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
options = await element.querySelectorAll('option')
options = await element.query_selector_all('option')
selected_labels = []
for option in options:
selected_labels.append((await (await option.getProperty('textContent')).jsonValue()))
selected_labels.append((await (await option.get_property('textContent')).json_value()))
return selected_labels

async def get_selected_list_values(self, locator: str) -> str:
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
options = await element.querySelectorAll('option:checked')
options = await element.query_selector_all('option:checked')
selected_labels = []
for option in options:
selected_labels.append((await (await option.getProperty('value')).jsonValue()))
selected_labels.append((await (await option.get_property('value')).json_value()))
return selected_labels

async def get_list_values(self, locator: str) -> str:
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
options = await element.querySelectorAll('option')
options = await element.query_selector_all('option')
selected_labels = []
for option in options:
selected_labels.append((await (await option.getProperty('value')).jsonValue()))
selected_labels.append((await (await option.get_property('value')).json_value()))
return selected_labels
16 changes: 8 additions & 8 deletions PuppeteerLibrary/playwright/async_keywords/playwright_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def click_element(self, locator: str, noWaitAfter: str='False'):
noWaitAfter = str2bool(noWaitAfter)
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
await element.click(
noWaitAfter=noWaitAfter
no_wait_after=noWaitAfter
)

async def click_link(self, locator: str):
Expand All @@ -36,7 +36,7 @@ async def click_image(self, locator: str):
async def _click_with_specific_tag(self, locator: str, expect_tag_name: str):
elements = await self.library_ctx.get_current_page().querySelectorAll_with_selenium_locator(locator)
for element in elements:
tag_name = await (await element.getProperty('tagName')).jsonValue()
tag_name = await (await element.get_property('tagName')).json_value()
if tag_name.lower() == expect_tag_name:
return await element.click()
raise Exception('Can\'t find the specific '+ expect_tag_name +' element for '+locator)
Expand All @@ -51,7 +51,7 @@ async def click_element_at_coordinate(self, locator: str, xoffset: str, yoffset:

async def upload_file(self, locator: str, file_path: str):
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
await element.setInputFiles(file_path)
await element.set_input_files(file_path)

async def press_keys(self, locator: str, *keys: str):
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
Expand All @@ -63,14 +63,14 @@ async def press_keys(self, locator: str, *keys: str):
##############################
async def element_should_be_enabled(self, locator: str):
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
is_disabled = await (await element.getProperty('disabled')).jsonValue()
is_disabled = await (await element.get_property('disabled')).json_value()
if is_disabled:
raise AssertionError("Element '%s' is disabled. " % locator)
return element

async def element_should_be_disabled(self, locator: str):
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
is_disabled = await (await element.getProperty('disabled')).jsonValue()
is_disabled = await (await element.get_property('disabled')).json_value()
if not is_disabled:
raise AssertionError("Element '%s' is enabled. " % locator)
return element
Expand Down Expand Up @@ -100,11 +100,11 @@ async def element_should_not_contain(self, locator: str, expected: str, ignore_c

async def get_text(self, locator: str):
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
return (await (await element.getProperty('innerText')).jsonValue())
return (await (await element.get_property('innerText')).json_value())

async def get_attribute(self, locator: str, attribute: str) -> str:
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
return (await (await element.getProperty(attribute)).jsonValue())
return (await (await element.get_property(attribute)).json_value())

async def element_text_should_be(self, locator: str, expected: str, ignore_case=False):
text = await self.get_text(locator)
Expand All @@ -119,4 +119,4 @@ async def element_text_should_not_be(self, locator: str, expected: str, ignore_c
##############################
async def scroll_element_into_view(self, locator: str):
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
await element.scrollIntoViewIfNeeded()
await element.scroll_into_view_if_needed()
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ async def clear_element_text(self, locator: str):
async def download_file(self, locator: str, timeout=None):
timeout = self.timestr_to_secs_for_default_timeout(timeout)* 1000
page = self.library_ctx.get_current_page().get_page()
tasks = self.library_ctx.get_current_page().click_with_selenium_locator(locator), page.waitForEvent('download', timeout=timeout)
tasks = self.library_ctx.get_current_page().click_with_selenium_locator(locator), page.wait_for_event('download', timeout=timeout)
_, b = await asyncio.gather(*tasks)
return await b.path()
path = str(await b.path())
return path.replace('\\', '\\\\')

async def upload_file(self, locator: str, file_path: str):
handle = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
await handle.setInputFiles(file_path)
await handle.set_input_files(file_path)

async def _clear_input_text(self, selenium_locator):
await self.library_ctx.get_current_page().click_with_selenium_locator(selenium_locator, {'clickCount': 3})
await self.library_ctx.get_current_page().click_with_selenium_locator(selenium_locator, {'click_count': 3})
await self.library_ctx.get_current_page().get_page().keyboard.press('Backspace')
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async def mouse_over(self, locator):

async def mouse_down(self, locator):
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
bounding_box = await element.boundingBox()
bounding_box = await element.bounding_box()
await self.library_ctx.get_current_page().get_page().mouse.move(
bounding_box['x'] + bounding_box['width'] / 2,
bounding_box['y'] + bounding_box['height'] / 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def __init__(self, library_ctx):

async def print_as_pdf(self, filename=DEFAULT_FILENAME_PAGE):
path = self._get_pdf_path(filename)
await self.library_ctx.get_current_page().get_page().emulateMedia('screen')
await self.library_ctx.get_current_page().get_page().emulate_media()
await self.library_ctx.get_current_page().get_page().pdf(path=path)
self.info('Print as pdf: '+path)
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ def __init__(self, library_ctx):
async def capture_page_screenshot(self, path: str, fullPage: bool):
return await self.library_ctx.get_current_page().get_page().screenshot(
path=f''+path,
fullPage=fullPage
full_page=fullPage
)
29 changes: 16 additions & 13 deletions PuppeteerLibrary/playwright/async_keywords/playwright_waiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ def __init__(self, library_ctx):
super().__init__(library_ctx)

async def wait_for_request_url(self, url, method='GET', body=None, timeout=None):
req = await self.library_ctx.get_current_page().get_page().waitForEvent(
"request", lambda request: re.search(url, request.url) is not None and request.method == method,
self.timestr_to_secs_for_default_timeout(timeout) * 1000
req = await self.library_ctx.get_current_page().get_page().wait_for_event(
"request",
predicate=lambda request: re.search(url, request.url) is not None and request.method == method,
timeout=self.timestr_to_secs_for_default_timeout(timeout) * 1000
)
try:
pos_data = (await req.postData())
Expand All @@ -35,9 +36,10 @@ async def wait_for_request_url(self, url, method='GET', body=None, timeout=None)
})

async def wait_for_response_url(self, url, status=200, body=None, timeout=None):
res = await self.library_ctx.get_current_page().get_page().waitForEvent(
"response", lambda response: re.search(url, response.url) is not None and response.status == int(status),
self.timestr_to_secs_for_default_timeout(timeout) * 1000
res = await self.library_ctx.get_current_page().get_page().wait_for_event(
"response",
predicate=lambda response: re.search(url, response.url) is not None and response.status == int(status),
timeout=self.timestr_to_secs_for_default_timeout(timeout) * 1000
)
try:
res_text = (await res.text())
Expand All @@ -57,9 +59,10 @@ async def wait_for_response_url(self, url, status=200, body=None, timeout=None):
})

async def wait_for_navigation(self, timeout=None):
await self.library_ctx.get_current_page().get_page().waitForNavigation(
timeout=self.timestr_to_secs_for_default_timeout(timeout) * 1000
)
return await self.library_ctx.get_current_page().get_page().wait_for_event(
'load',
predicate=None,
timeout=self.timestr_to_secs_for_default_timeout(timeout) * 1000)

async def wait_until_page_contains_element(self, locator, timeout=None):
return await self._wait_for_selenium_selector(locator, timeout, visible=True, hidden=False)
Expand All @@ -85,7 +88,7 @@ async def wait_until_element_contains(self, locator, text, timeout=None):
async def wait_until_element_does_not_contains(self, locator, text, timeout=None):
async def validate_element_contains_text():
return (text not in (await (await ( await self.library_ctx.get_current_page().
querySelector_with_selenium_locator(locator)).getProperty('textContent')).jsonValue()))
querySelector_with_selenium_locator(locator)).get_property('textContent')).json_value()))
return await self._wait_until_worker(
validate_element_contains_text,
self.timestr_to_secs_for_default_timeout(timeout))
Expand All @@ -107,7 +110,7 @@ async def validate_url_not_contains_text():
async def wait_until_element_is_enabled(self, locator, timeout=None):
async def validate_is_enabled():
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
is_disabled = await (await element.getProperty('disabled')).jsonValue()
is_disabled = await (await element.get_property('disabled')).json_value()
return is_disabled == False
return await self._wait_until_worker(
validate_is_enabled,
Expand All @@ -120,10 +123,10 @@ async def check_finished_animating():
await self.wait_until_element_is_visible(locator)
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
if prev_rect_tmp['value'] is None:
prev_rect_tmp['value'] = await element.boundingBox()
prev_rect_tmp['value'] = await element.bounding_box()
return False
prev_rect = prev_rect_tmp['value']
next_rect = await element.boundingBox()
next_rect = await element.bounding_box()
if next_rect['x'] == prev_rect['x'] and next_rect['y'] == prev_rect['y']:
return True
else:
Expand Down
Loading

0 comments on commit c5c0f79

Please sign in to comment.