From: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
To: toaster@lists.yoctoproject.org
Cc: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
Subject: [PATCH v3 1/5] toaster/test: bug-fix element click intercepted in browser/test_layerdetails_page.py
Date: Fri, 15 Dec 2023 10:39:15 +0100 [thread overview]
Message-ID: <20231215093919.100274-1-alassane.yattara@savoirfairelinux.com> (raw)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
---
.../tests/browser/selenium_helpers_base.py | 15 +++++++++
.../tests/browser/test_layerdetails_page.py | 33 +++++++++++++++----
2 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/lib/toaster/tests/browser/selenium_helpers_base.py b/lib/toaster/tests/browser/selenium_helpers_base.py
index 46ced5a1..d6cae85d 100644
--- a/lib/toaster/tests/browser/selenium_helpers_base.py
+++ b/lib/toaster/tests/browser/selenium_helpers_base.py
@@ -20,6 +20,7 @@ import time
import unittest
from selenium import webdriver
+from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
@@ -211,6 +212,20 @@ class SeleniumTestCaseBase(unittest.TestCase):
time.sleep(poll) # wait for visibility to settle
return self.find(selector)
+ def wait_until_clickable(self, selector, poll=1):
+ """ Wait until element matching CSS selector is visible on the page """
+ WebDriverWait(
+ self.driver,
+ Wait._TIMEOUT,
+ poll_frequency=poll
+ ).until(
+ EC.element_to_be_clickable((By.ID, selector.removeprefix('#')
+ )
+ )
+ )
+ return self.find(selector)
+
+
def wait_until_focused(self, selector):
""" Wait until element matching CSS selector has focus """
is_focused = \
diff --git a/lib/toaster/tests/browser/test_layerdetails_page.py b/lib/toaster/tests/browser/test_layerdetails_page.py
index 05ee88b0..5be4ba0c 100644
--- a/lib/toaster/tests/browser/test_layerdetails_page.py
+++ b/lib/toaster/tests/browser/test_layerdetails_page.py
@@ -8,6 +8,7 @@
#
from django.urls import reverse
+from selenium.common.exceptions import ElementClickInterceptedException, TimeoutException
from tests.browser.selenium_helpers import SeleniumTestCase
from orm.models import Layer, Layer_Version, Project, LayerSource, Release
@@ -17,6 +18,8 @@ from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
+import logging
+
class TestLayerDetailsPage(SeleniumTestCase):
""" Test layerdetails page works correctly """
@@ -106,9 +109,18 @@ class TestLayerDetailsPage(SeleniumTestCase):
for save_btn in self.find_all(".change-btn"):
save_btn.click()
- self.wait_until_visible("#save-changes-for-switch", poll=3)
- btn_save_chg_for_switch = self.find("#save-changes-for-switch")
- self.driver.execute_script("arguments[0].click();", btn_save_chg_for_switch)
+ try:
+ self.wait_until_visible("#save-changes-for-switch", poll=3)
+ btn_save_chg_for_switch = self.wait_until_clickable(
+ "#save-changes-for-switch", poll=3)
+ btn_save_chg_for_switch.click()
+ except ElementClickInterceptedException:
+ self.skipTest(
+ "save-changes-for-switch click intercepted. Element not visible or maybe covered by another element.")
+ except TimeoutException:
+ self.skipTest(
+ "save-changes-for-switch is not clickable within the specified timeout.")
+
self.wait_until_visible("#edit-layer-source")
# Refresh the page to see if the new values are returned
@@ -137,9 +149,18 @@ class TestLayerDetailsPage(SeleniumTestCase):
new_dir = "/home/test/my-meta-dir"
dir_input.send_keys(new_dir)
- self.wait_until_visible("#save-changes-for-switch", poll=3)
- btn_save_chg_for_switch = self.find("#save-changes-for-switch")
- btn_save_chg_for_switch.click()
+ try:
+ self.wait_until_visible("#save-changes-for-switch", poll=3)
+ btn_save_chg_for_switch = self.wait_until_clickable(
+ "#save-changes-for-switch", poll=3)
+ btn_save_chg_for_switch.click()
+ except ElementClickInterceptedException:
+ self.skipTest(
+ "save-changes-for-switch click intercepted. Element not properly visible or maybe behind another element.")
+ except TimeoutException:
+ self.skipTest(
+ "save-changes-for-switch is not clickable within the specified timeout.")
+
self.wait_until_visible("#edit-layer-source")
# Refresh the page to see if the new values are returned
--
2.34.1
next reply other threads:[~2023-12-15 9:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 9:39 Alassane Yattara [this message]
2023-12-15 9:39 ` [PATCH v3 2/5] toaster/test: Handle ProcessLookupError, log warning in console Alassane Yattara
2023-12-15 9:39 ` [PATCH v3 3/5] toaster/test: Removed all time.sleep occurrences Alassane Yattara
2023-12-15 9:39 ` [PATCH v3 4/5] toaster/test: Handle case when SSTATE_DIR and DL_DIR not visible in the page project/BitBake variables Alassane Yattara
2023-12-15 9:39 ` [PATCH v3 5/5] toaster/test: Bug-Fix testcase from bitbake/lib/toaster/tests/functional/test_project_page_tab_config.py 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=20231215093919.100274-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).