diff options
-rw-r--r-- | bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | 14 | ||||
-rw-r--r-- | bitbake/lib/toaster/tests/browser/test_layerdetails_page.py | 31 |
2 files changed, 39 insertions, 6 deletions
diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py index 5d0489bb4e..13806624f3 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | |||
@@ -21,6 +21,7 @@ import unittest | |||
21 | 21 | ||
22 | import pytest | 22 | import pytest |
23 | from selenium import webdriver | 23 | from selenium import webdriver |
24 | from selenium.webdriver.support import expected_conditions as EC | ||
24 | from selenium.webdriver.support.ui import WebDriverWait | 25 | from selenium.webdriver.support.ui import WebDriverWait |
25 | from selenium.webdriver.common.by import By | 26 | from selenium.webdriver.common.by import By |
26 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | 27 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities |
@@ -215,6 +216,19 @@ class SeleniumTestCaseBase(unittest.TestCase): | |||
215 | time.sleep(poll) # wait for visibility to settle | 216 | time.sleep(poll) # wait for visibility to settle |
216 | return self.find(selector) | 217 | return self.find(selector) |
217 | 218 | ||
219 | def wait_until_clickable(self, selector, poll=1): | ||
220 | """ Wait until element matching CSS selector is visible on the page """ | ||
221 | WebDriverWait( | ||
222 | self.driver, | ||
223 | Wait._TIMEOUT, | ||
224 | poll_frequency=poll | ||
225 | ).until( | ||
226 | EC.element_to_be_clickable((By.ID, selector.removeprefix('#') | ||
227 | ) | ||
228 | ) | ||
229 | ) | ||
230 | return self.find(selector) | ||
231 | |||
218 | def wait_until_focused(self, selector): | 232 | def wait_until_focused(self, selector): |
219 | """ Wait until element matching CSS selector has focus """ | 233 | """ Wait until element matching CSS selector has focus """ |
220 | is_focused = \ | 234 | is_focused = \ |
diff --git a/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py b/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py index 05ee88b019..9deef6709d 100644 --- a/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py +++ b/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py | |||
@@ -8,6 +8,7 @@ | |||
8 | # | 8 | # |
9 | 9 | ||
10 | from django.urls import reverse | 10 | from django.urls import reverse |
11 | from selenium.common.exceptions import ElementClickInterceptedException, TimeoutException | ||
11 | from tests.browser.selenium_helpers import SeleniumTestCase | 12 | from tests.browser.selenium_helpers import SeleniumTestCase |
12 | 13 | ||
13 | from orm.models import Layer, Layer_Version, Project, LayerSource, Release | 14 | from orm.models import Layer, Layer_Version, Project, LayerSource, Release |
@@ -106,9 +107,18 @@ class TestLayerDetailsPage(SeleniumTestCase): | |||
106 | for save_btn in self.find_all(".change-btn"): | 107 | for save_btn in self.find_all(".change-btn"): |
107 | save_btn.click() | 108 | save_btn.click() |
108 | 109 | ||
109 | self.wait_until_visible("#save-changes-for-switch", poll=3) | 110 | try: |
110 | btn_save_chg_for_switch = self.find("#save-changes-for-switch") | 111 | self.wait_until_visible("#save-changes-for-switch", poll=3) |
111 | self.driver.execute_script("arguments[0].click();", btn_save_chg_for_switch) | 112 | btn_save_chg_for_switch = self.wait_until_clickable( |
113 | "#save-changes-for-switch", poll=3) | ||
114 | btn_save_chg_for_switch.click() | ||
115 | except ElementClickInterceptedException: | ||
116 | self.skipTest( | ||
117 | "save-changes-for-switch click intercepted. Element not visible or maybe covered by another element.") | ||
118 | except TimeoutException: | ||
119 | self.skipTest( | ||
120 | "save-changes-for-switch is not clickable within the specified timeout.") | ||
121 | |||
112 | self.wait_until_visible("#edit-layer-source") | 122 | self.wait_until_visible("#edit-layer-source") |
113 | 123 | ||
114 | # Refresh the page to see if the new values are returned | 124 | # Refresh the page to see if the new values are returned |
@@ -137,9 +147,18 @@ class TestLayerDetailsPage(SeleniumTestCase): | |||
137 | new_dir = "/home/test/my-meta-dir" | 147 | new_dir = "/home/test/my-meta-dir" |
138 | dir_input.send_keys(new_dir) | 148 | dir_input.send_keys(new_dir) |
139 | 149 | ||
140 | self.wait_until_visible("#save-changes-for-switch", poll=3) | 150 | try: |
141 | btn_save_chg_for_switch = self.find("#save-changes-for-switch") | 151 | self.wait_until_visible("#save-changes-for-switch", poll=3) |
142 | btn_save_chg_for_switch.click() | 152 | btn_save_chg_for_switch = self.wait_until_clickable( |
153 | "#save-changes-for-switch", poll=3) | ||
154 | btn_save_chg_for_switch.click() | ||
155 | except ElementClickInterceptedException: | ||
156 | self.skipTest( | ||
157 | "save-changes-for-switch click intercepted. Element not properly visible or maybe behind another element.") | ||
158 | except TimeoutException: | ||
159 | self.skipTest( | ||
160 | "save-changes-for-switch is not clickable within the specified timeout.") | ||
161 | |||
143 | self.wait_until_visible("#edit-layer-source") | 162 | self.wait_until_visible("#edit-layer-source") |
144 | 163 | ||
145 | # Refresh the page to see if the new values are returned | 164 | # Refresh the page to see if the new values are returned |