From: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
To: toaster@lists.yoctoproject.org
Cc: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
Subject: [PATCH 1/9] toaster/tests: Update methods wait_until_~ to skip using time.sleep
Date: Wed, 29 Nov 2023 23:53:32 +0100 [thread overview]
Message-ID: <20231129225340.477401-1-alassane.yattara@savoirfairelinux.com> (raw)
Update Class Wait from selenium_helpers_base, to override
wait_until_visible and wait_until_present with poll argument to better
handle delay between driver actions
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
---
lib/toaster/tests/browser/selenium_helpers_base.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/lib/toaster/tests/browser/selenium_helpers_base.py b/lib/toaster/tests/browser/selenium_helpers_base.py
index e0ac4376..d9ea7fd1 100644
--- a/lib/toaster/tests/browser/selenium_helpers_base.py
+++ b/lib/toaster/tests/browser/selenium_helpers_base.py
@@ -71,7 +71,9 @@ class Wait(WebDriverWait):
_TIMEOUT = 10
_POLL_FREQUENCY = 0.5
- def __init__(self, driver):
+ def __init__(self, driver, timeout=_TIMEOUT, poll=_POLL_FREQUENCY):
+ self._TIMEOUT = timeout
+ self._POLL_FREQUENCY = poll
super(Wait, self).__init__(driver, self._TIMEOUT, self._POLL_FREQUENCY)
def until(self, method, message=''):
@@ -175,18 +177,19 @@ class SeleniumTestCaseBase(unittest.TestCase):
""" Return the element which currently has focus on the page """
return self.driver.switch_to.active_element
- def wait_until_present(self, selector):
+ def wait_until_present(self, selector, poll=0.5):
""" Wait until element matching CSS selector is on the page """
is_present = lambda driver: self.find(selector)
msg = 'An element matching "%s" should be on the page' % selector
- element = Wait(self.driver).until(is_present, msg)
+ element = Wait(self.driver, poll=poll).until(is_present, msg)
return element
- def wait_until_visible(self, selector):
+ def wait_until_visible(self, selector, poll=1):
""" Wait until element matching CSS selector is visible on the page """
is_visible = lambda driver: self.find(selector).is_displayed()
msg = 'An element matching "%s" should be visible' % selector
- Wait(self.driver).until(is_visible, msg)
+ Wait(self.driver, poll=poll).until(is_visible, msg)
+ time.sleep(poll) # wait for visibility to settle
return self.find(selector)
def wait_until_focused(self, selector):
--
2.34.1
next reply other threads:[~2023-11-29 22:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 22:53 Alassane Yattara [this message]
2023-11-29 22:53 ` [PATCH 2/9] toaster/test: Override table edit columns TestCase from image recipe page Alassane Yattara
2023-11-29 22:53 ` [PATCH 3/9] toaster/test: Test software " Alassane Yattara
2023-11-29 22:53 ` [PATCH 4/9] toaster/test: Added Machine page TestCase Alassane Yattara
2023-11-29 22:53 ` [PATCH 5/9] toaster/test: Added Layers " Alassane Yattara
2023-11-29 22:53 ` [PATCH 6/9] toaster/test: Added distro " Alassane Yattara
2023-11-30 17:28 ` [Toaster] " Richard Purdie
2023-11-30 18:29 ` Alassane Yattara
2023-11-30 22:24 ` Richard Purdie
2023-11-30 22:43 ` Alassane Yattara
2023-11-29 22:53 ` [PATCH 7/9] toaster/test: Bug-fix on tests/functional/test_project_page Alassane Yattara
2023-11-29 22:53 ` [PATCH 8/9] toaster/test: Test single layer page Alassane Yattara
2023-11-29 22:53 ` [PATCH 9/9] toaster/test: Test single recipe page Alassane Yattara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231129225340.477401-1-alassane.yattara@savoirfairelinux.com \
--to=alassane.yattara@savoirfairelinux.com \
--cc=toaster@lists.yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).