Skip to content

Commit 0fe8c89

Browse files
authored
Fix bug get title get location & apply playwright auto wait (#136)
* Update playwright version * Fixed attribute keyword issue * Improve with playwright auto-wait * Revert back to v15 * Ignore puppeteer for webkit test Co-authored-by: DESKTOP\atthaboon.s <atthaboon.s@qahive.com>
1 parent fba8f5c commit 0fe8c89

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
*** Settings ***
2+
Library PuppeteerLibrary
3+
Suite Teardown Close Puppeteer
4+
Test Teardown Close All Browser
5+
6+
*** Variables ***
7+
${DEFAULT_BROWSER} chrome
8+
9+
10+
*** Test Cases ***
11+
Get page title
12+
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
13+
${HEADLESS} = Get variable value ${HEADLESS} ${False}
14+
&{options} = create dictionary headless=${HEADLESS}
15+
Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} options=${options}
16+
${title} = Get Title
17+
Should Be Equal As Strings Basic HTML Elements ${title}
18+
19+
Get url
20+
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
21+
${HEADLESS} = Get variable value ${HEADLESS} ${False}
22+
&{options} = create dictionary headless=${HEADLESS}
23+
Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} options=${options}
24+
${url} = Get Location
25+
Should Contain ${url} basic-html-elements.html

Examples/browser-management/webkit-newpage-limitation.robot

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Test Teardown Close All Browser
66

77
*** Test Cases ***
88
Webkit new page cause exception require ignore waiting
9-
[Tags] Ignore_chrome Ignore_pwchrome Ignore_firefox
9+
[Tags] Ignore_chrome Ignore_pwchrome Ignore_firefox Ignore_ptchrome
1010
${BROWSER} = Get variable value ${BROWSER} webkit
1111
${HEADLESS} = Get variable value ${HEADLESS} ${False}
1212
&{options} = create dictionary headless=${HEADLESS}

PuppeteerLibrary/keywords/browsermanagement.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ def close_puppeteer(self):
8888
@keyword
8989
def get_title(self):
9090
"""Get page title"""
91-
async def get_title_async():
92-
return await self.ctx.get_current_page().title()
93-
return self.loop.run_until_complete(get_title_async())
91+
return self.loop.run_until_complete(self.ctx.get_current_library_context().get_current_page().title())
9492

9593
@keyword
9694
def get_location(self):
9795
"""Get page location"""
98-
return self.ctx.get_current_page().url
96+
return self.ctx.get_current_library_context().get_current_page().get_page().url
9997

10098
@keyword
10199
def go_back(self):

PuppeteerLibrary/playwright/custom_elements/playwright_page.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ async def click_with_selenium_locator(self, selenium_locator: str, options: dict
5858
async def type_with_selenium_locator(self, selenium_locator: str, text: str, options: dict = None, **kwargs: Any):
5959
selector_value = SelectorAbstraction.get_selector(selenium_locator)
6060
if options is None:
61-
options = {}
61+
options = { 'state': 'visible' }
6262
if self.selected_iframe is not None:
63-
return await self.selected_iframe.type(selector=selector_value, text=text, **options)
63+
await self.selected_iframe.wait_for_selector(selector=selector_value, **options)
64+
return await self.selected_iframe.type(selector=selector_value, text=text)
6465
else:
65-
return await self.page.type(selector=selector_value, text=text, **options)
66+
await self.page.wait_for_selector(selector=selector_value, **options)
67+
return await self.page.type(selector=selector_value, text=text)
6668

6769
############
6870
# Wait
@@ -95,15 +97,19 @@ async def waitForSelector_with_selenium_locator(self, selenium_locator: str, tim
9597
async def querySelectorAll_with_selenium_locator(self, selenium_locator: str):
9698
selector_value = SelectorAbstraction.get_selector(selenium_locator)
9799
if self.selected_iframe is not None:
100+
await self.selected_iframe.wait_for_selector(selector=selector_value)
98101
return await self.selected_iframe.query_selector_all(selector_value)
99102
else:
103+
await self.get_page().wait_for_selector(selector=selector_value)
100104
return await self.get_page().query_selector_all(selector_value)
101105

102106
async def querySelector_with_selenium_locator(self, selenium_locator: str):
103107
selector_value = SelectorAbstraction.get_selector(selenium_locator)
104108
if self.selected_iframe is not None:
109+
await self.selected_iframe.wait_for_selector(selector=selector_value)
105110
return await self.selected_iframe.query_selector(selector_value)
106111
else:
112+
await self.get_page().wait_for_selector(selector=selector_value)
107113
return await self.get_page().query_selector(selector_value)
108114

109115
############

0 commit comments

Comments
 (0)