|
| 1 | +from robot.libraries.BuiltIn import BuiltIn |
| 2 | + |
1 | 3 | from PuppeteerLibrary.base.robotlibcore import keyword |
2 | 4 | from PuppeteerLibrary.base.librarycomponent import LibraryComponent |
3 | 5 |
|
@@ -44,3 +46,53 @@ async def get_text_async(self, selenium_locator): |
44 | 46 | async def get_value_async(self, selenium_locator): |
45 | 47 | element = await self.ctx.get_current_page().querySelector_with_selenium_locator(selenium_locator) |
46 | 48 | return (await (await element.getProperty('value')).jsonValue()) |
| 49 | + |
| 50 | + @keyword |
| 51 | + async def element_should_be_disabled_async(self, selenium_locator): |
| 52 | + element = await self.ctx.get_current_page().querySelector_with_selenium_locator(selenium_locator) |
| 53 | + is_disabled = await (await element.getProperty('disabled')).jsonValue() |
| 54 | + if not is_disabled: |
| 55 | + raise AssertionError("Element '%s' is enabled. " % selenium_locator) |
| 56 | + return element |
| 57 | + |
| 58 | + @keyword |
| 59 | + async def element_should_be_enabled_async(self, selenium_locator): |
| 60 | + element = await self.ctx.get_current_page().querySelector_with_selenium_locator(selenium_locator) |
| 61 | + is_disabled = await (await element.getProperty('disabled')).jsonValue() |
| 62 | + if is_disabled: |
| 63 | + raise AssertionError("Element '%s' is disabled. " % selenium_locator) |
| 64 | + return element |
| 65 | + |
| 66 | + @keyword |
| 67 | + async def element_should_be_visible_async(self, selenium_locator): |
| 68 | + try: |
| 69 | + return await self.ctx.get_current_page().waitForSelector_with_selenium_locator(selenium_locator, 0.1, visible=True, hidden=False) |
| 70 | + except: |
| 71 | + raise AssertionError("Element '%s' is not be visible. " % selenium_locator) |
| 72 | + |
| 73 | + @keyword |
| 74 | + async def element_should_not_be_visible_async(self, selenium_locator): |
| 75 | + try: |
| 76 | + return await self.ctx.get_current_page().waitForSelector_with_selenium_locator(selenium_locator, 0.1, visible=False, hidden=True) |
| 77 | + except: |
| 78 | + raise AssertionError("Element '%s' is visible. " % selenium_locator) |
| 79 | + |
| 80 | + @keyword |
| 81 | + async def element_should_contain_async(self, selenium_locator, expected, ignore_case=False): |
| 82 | + text = await self.get_text_async(selenium_locator) |
| 83 | + return BuiltIn().should_contain(text, expected, ignore_case=ignore_case) |
| 84 | + |
| 85 | + @keyword |
| 86 | + async def element_should_not_contain_async(self, selenium_locator, expected, ignore_case=False): |
| 87 | + text = await self.get_text_async(selenium_locator) |
| 88 | + return BuiltIn().should_not_contain(text, expected, ignore_case=ignore_case) |
| 89 | + |
| 90 | + @keyword |
| 91 | + async def element_text_should_be_async(self, selenium_locator, expected, ignore_case=False): |
| 92 | + text = await self.get_text_async(selenium_locator) |
| 93 | + return BuiltIn().should_be_equal_as_strings(text, expected, ignore_case=ignore_case) |
| 94 | + |
| 95 | + @keyword |
| 96 | + async def element_text_should_not_be_async(self, selenium_locator, expected, ignore_case=False): |
| 97 | + text = await self.get_text_async(selenium_locator) |
| 98 | + return BuiltIn().should_not_be_equal_as_strings(text, expected, ignore_case=ignore_case) |
0 commit comments