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
11 changes: 11 additions & 0 deletions Examples/wait-for-demo.robot
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,14 @@ Demo wait for location contains
Go To ${HOME_PAGE_URL}/docs.html
Switch Window NEW
Wait Until Location Contains docs.html

Demo wait for element is enabled
${HEADLESS} Get variable value ${HEADLESS} ${False}
&{options} = create dictionary headless=${HEADLESS}
Open browser ${HOME_PAGE_URL} options=${options}
Go To ${HOME_PAGE_URL}/form.html
Wait Until Element Is Enabled id=disable_button
Click Element id=disable_button
Wait Until Page Contains Login succeeded


9 changes: 9 additions & 0 deletions PuppeteerLibrary/keywords/waiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,12 @@ def wait_until_location_does_not_contains(self, expected, timeout=None):
The `expected` argument contains the expected value must not in url.
"""
return self.loop.run_until_complete(self.async_func.wait_until_location_does_not_contains_async(expected, timeout))

@keyword
def wait_until_element_is_enabled(self, selenium_locator, timeout=None):
"""
Waits until the specific element is Enabled.

"""
return self.loop.run_until_complete(
self.async_func.wait_until_element_is_enabled_async(selenium_locator, timeout))
11 changes: 11 additions & 0 deletions PuppeteerLibrary/keywords/waiting_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ async def validate_url_not_contains_text():
validate_url_not_contains_text,
self.timestr_to_secs_for_default_timeout(timeout))

@keyword
async def wait_until_element_is_enabled_async(self, selenium_locator, timeout=None):
async def validate_is_enabled():
element = await self.ctx.get_current_page().querySelector_with_selenium_locator(selenium_locator)
is_disabled = await (await element.getProperty('disabled')).jsonValue()
return is_disabled == False
return await self._wait_until_worker(
validate_is_enabled,
self.timestr_to_secs_for_default_timeout(timeout),
'Element '+selenium_locator+' was not enabled.')

async def _wait_until_worker(self, condition, timeout, error=None):
max_time = time.time() + timeout
not_found = None
Expand Down
13 changes: 12 additions & 1 deletion demoapp/html/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
</div>
</div>
<button id="disable_button" disabled onclick="goto();">disable button</button>

<script>
setTimeout(function(){
document.getElementById('disable_button').disabled = false; }
, 2000);

function goto() {
window.location = "welcome.html";
}
</script>
</body>
</html>