From patchwork Wed Nov 29 22:53:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 35377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3608FC4167B for ; Wed, 29 Nov 2023 22:53:58 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.57398.1701298435280145659 for ; Wed, 29 Nov 2023 14:53:56 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=mpMznoEF; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alassane.yattara@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id A1C649C3DB1 for ; Wed, 29 Nov 2023 17:53:53 -0500 (EST) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id 1c696LfN-4M5; Wed, 29 Nov 2023 17:53:53 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 342CC9C34C4; Wed, 29 Nov 2023 17:53:53 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 342CC9C34C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1701298433; bh=b+X1Nxo9h2mxAwycXWsbLpYJ/UbzQ3mGaMOTvM09yYk=; h=From:To:Date:Message-Id:MIME-Version; b=mpMznoEFPsSwRVMpIsQJPb2sFL5v8tp9SFC2SPyLl5OoDxp4YlXipUK6n2hmspzVE +D/KBho0mDKCfF1N2FzZDO4P6WrMqHgCO62ZTZocB5Wrem6KN8elWTE+rZmD6rvE+z osM5Vc1CBlIFc3jwuYHNF7yFEgHtm+hf0G35+mJpYTojSTGwtj7TimStBUsAC5r710 ACOrCPCD8goxDCEvqLFBchUjQ7ZOop4Y7uPVGN1/PUV0SHxD3Xw70HighwiVwifNG6 VgEIvU5S43JmcuzIsn2gawI5TyiGtvB6/ISTkp3Hy/EoqJLlLr++tNwUg00Wn3h2nH zGI0c5lbdDuLg== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id a6UKD3XYksnk; Wed, 29 Nov 2023 17:53:53 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 9C2089C2797; Wed, 29 Nov 2023 17:53:52 -0500 (EST) From: Alassane Yattara To: toaster@lists.yoctoproject.org Cc: Alassane Yattara Subject: [PATCH 1/9] toaster/tests: Update methods wait_until_~ to skip using time.sleep Date: Wed, 29 Nov 2023 23:53:32 +0100 Message-Id: <20231129225340.477401-1-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 29 Nov 2023 22:53:58 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/6025 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 --- 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):