Skip to content

Commit

Permalink
Add extra dropdown keywords (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
atthaboon authored Jan 20, 2021
1 parent a4a5d29 commit 29a239e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
10 changes: 9 additions & 1 deletion PuppeteerLibrary/ikeywords/idropdown_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ async def select_from_list_by_label(self, locator, labels):
async def get_selected_list_labels(self, locator: str) -> str:
pass

@abstractmethod
async def get_list_labels(self, locator: str) -> str:
pass

@abstractmethod
async def get_selected_list_values(self, locator: str) -> str:
pass
pass

@abstractmethod
async def get_list_values(self, locator: str) -> str:
pass
10 changes: 10 additions & 0 deletions PuppeteerLibrary/keywords/dropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def get_selected_list_labels(self, locator):
"""
return self.loop.run_until_complete(self.get_async_keyword_group().get_selected_list_labels(locator))

@keyword
def get_list_labels(self, locator):
""" Return the label list of options from element.
"""
return self.loop.run_until_complete(self.get_async_keyword_group().get_list_labels(locator))

@keyword
def get_selected_list_value(self, locator):
Expand All @@ -53,4 +58,9 @@ def get_selected_list_values(self, locator):
"""
return self.loop.run_until_complete(self.get_async_keyword_group().get_selected_list_values(locator))

@keyword
def get_list_values(self, locator):
""" Return the value list of options from element.
"""
return self.loop.run_until_complete(self.get_async_keyword_group().get_list_values(locator))

16 changes: 16 additions & 0 deletions PuppeteerLibrary/playwright/async_keywords/playwright_dropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,26 @@ async def get_selected_list_labels(self, locator: str) -> str:
selected_labels.append((await (await option.getProperty('textContent')).jsonValue()))
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')
selected_labels = []
for option in options:
selected_labels.append((await (await option.getProperty('textContent')).jsonValue()))
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')
selected_labels = []
for option in options:
selected_labels.append((await (await option.getProperty('value')).jsonValue()))
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')
selected_labels = []
for option in options:
selected_labels.append((await (await option.getProperty('value')).jsonValue()))
return selected_labels
15 changes: 15 additions & 0 deletions PuppeteerLibrary/puppeteer/async_keywords/puppeteer_dropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ async def get_selected_list_labels(self, locator: str) -> str:
selected_labels.append((await (await option.getProperty('textContent')).jsonValue()))
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')
selected_labels = []
for option in options:
selected_labels.append((await (await option.getProperty('textContent')).jsonValue()))
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')
Expand All @@ -42,3 +50,10 @@ async def get_selected_list_values(self, locator: str) -> str:
selected_labels.append((await (await option.getProperty('value')).jsonValue()))
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')
selected_labels = []
for option in options:
selected_labels.append((await (await option.getProperty('value')).jsonValue()))
return selected_labels

0 comments on commit 29a239e

Please sign in to comment.