diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py')
-rw-r--r-- | taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py | 110 |
1 files changed, 72 insertions, 38 deletions
diff --git a/taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py b/taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py index 781000981e..7788dabe34 100644 --- a/taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py +++ b/taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py @@ -10,7 +10,7 @@ import tempfile import time from basic_tests import SnapTestsBase -from selenium.common.exceptions import StaleElementReferenceException, TimeoutException +from selenium.common.exceptions import TimeoutException from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys @@ -35,7 +35,9 @@ class QATests(SnapTestsBase): if iframe_selector: self._logger.info("find iframe") - iframe = self._driver.find_element(By.CSS_SELECTOR, iframe_selector) + iframe = self._wait.until( + EC.visibility_of_element_located((By.CSS_SELECTOR, iframe_selector)) + ) self._driver.switch_to.frame(iframe) self._logger.info("find video") @@ -259,6 +261,15 @@ class QATests(SnapTestsBase): self._wait.until(lambda d: pdf_div.is_displayed() is True) return pdf_div + def is_esr(self): + self._driver.set_context("chrome") + update_channel = self._driver.execute_script( + "return Services.prefs.getStringPref('app.update.channel');" + ) + self._logger.info("Update channel: {}".format(update_channel)) + self._driver.set_context("content") + return update_channel == "esr" + def pdf_get_page(self, page, long=False): waiter = self._longwait if long is True else self._wait page = waiter.until( @@ -267,22 +278,26 @@ class QATests(SnapTestsBase): ) ) - try: - self._wait.until(lambda d: page.is_displayed() is True) - except StaleElementReferenceException as ex: - self._logger.info("Stale element but who cares?: {}".format(ex)) - time.sleep(2) - - # self._wait.until( - # lambda d: d.execute_script( - # 'return window.getComputedStyle(document.querySelector(".loadingInput.start"), "::after").getPropertyValue("visibility");' - # ) - # == "hidden" - # ) - - # PDF.js can take time to settle and we don't have a nice way to wait - # for an event on it - time.sleep(2) + if not self.is_esr(): + self._wait.until( + lambda d: d.execute_script( + 'return window.getComputedStyle(document.querySelector(".loadingInput.start"), "::after").getPropertyValue("visibility");' + ) + != "visible" + ) + # PDF.js can take time to settle and we don't have a nice way to wait + # for an event on it + time.sleep(1) + else: + self._logger.info("Running against ESR, just wait too much.") + # Big but let's be safe, this is only for ESR because its PDF.js + # does not have "<span class='loadingInput start'>" + time.sleep(10) + + # Rendering can be slower on debug build so give more time to settle + if self.is_debug_build(): + time.sleep(3) + return page def pdf_go_to_page(self, page): @@ -302,8 +317,8 @@ class QATests(SnapTestsBase): # Test basic rendering self.pdf_wait_div() self.pdf_select_zoom("1") - page_1 = self.pdf_get_page(1) - self.assert_rendering(exp["base"], page_1) + self.pdf_get_page(1) + self.assert_rendering(exp["base"], self._driver) # Navigating to page X, we know the PDF has 5 pages. rand_page = random.randint(1, 5) @@ -396,10 +411,37 @@ class QATests(SnapTestsBase): if menu_id == "pageRotateCw" or menu_id == "pageRotateCcw": secondary_menu.click() - time.sleep(0.2) + time.sleep(0.75) self._logger.info("assert {}".format(menu_id)) - self.assert_rendering(exp[menu_id], self._driver) + if self.is_esr() and menu_id == "documentProperties": + # on ESR pdf.js misreports in mm instead of inches + title = self._wait.until( + EC.visibility_of_element_located((By.ID, "titleField")) + ) + author = self._wait.until( + EC.visibility_of_element_located((By.ID, "authorField")) + ) + subject = self._wait.until( + EC.visibility_of_element_located((By.ID, "subjectField")) + ) + version = self._wait.until( + EC.visibility_of_element_located((By.ID, "versionField")) + ) + assert title.text == "PDF", "Incorrect PDF title reported: {}".format( + title + ) + assert ( + author.text == "Software 995" + ), "Incorrect PDF author reported: {}".format(author) + assert ( + subject.text == "Create PDF with Pdf 995" + ), "Incorrect PDF subject reported: {}".format(subject) + assert ( + version.text == "1.3" + ), "Incorrect PDF version reported: {}".format(version) + else: + self.assert_rendering(exp[menu_id], self._driver) if menu_id == "documentProperties": close = self._wait.until( @@ -423,6 +465,7 @@ class QATests(SnapTestsBase): ) ) action.drag_and_drop_by_offset(paragraph, 50, 10).perform() + time.sleep(0.75) self.assert_rendering(exp["select_text"], self._driver) # release select selection @@ -464,7 +507,7 @@ class QATests(SnapTestsBase): for zoom, page, ref in zoom_levels: self.pdf_select_zoom(zoom) - self.pdf_get_page(page) + self.pdf_get_page(page, long=True) self._logger.info("assert {}".format(ref)) self.assert_rendering(exp[ref], self._driver) @@ -704,17 +747,8 @@ class QATests(SnapTestsBase): download_dir_pref == new ), "download directory from pref should match new directory" - def open_thinkbroadband(self): - download_site = self.open_tab("https://www.thinkbroadband.com/download") - try: - consent = self._wait.until( - EC.visibility_of_element_located( - (By.CSS_SELECTOR, ".t-acceptAllButton") - ) - ) - consent.click() - except TimeoutException: - self._logger.info("Wait for consent form: timed out, maybe it is not here") + def open_lafibre(self): + download_site = self.open_tab("https://ip.lafibre.info/test-debit.php") return download_site def test_download_folder_change(self, exp): @@ -722,12 +756,12 @@ class QATests(SnapTestsBase): C1756713 """ - download_site = self.open_thinkbroadband() + download_site = self.open_lafibre() extra_small = self._wait.until( EC.presence_of_element_located( ( By.CSS_SELECTOR, - "div.module:nth-child(8) > p:nth-child(1) > a:nth-child(1)", + ".tableau > tbody:nth-child(1) > tr:nth-child(6) > td:nth-child(2) > a:nth-child(1)", ) ) ) @@ -775,12 +809,12 @@ class QATests(SnapTestsBase): C1756715 """ - download_site = self.open_thinkbroadband() + download_site = self.open_lafibre() extra_small = self._wait.until( EC.presence_of_element_located( ( By.CSS_SELECTOR, - "div.module:nth-child(8) > p:nth-child(1) > a:nth-child(1)", + ".tableau > tbody:nth-child(1) > tr:nth-child(6) > td:nth-child(2) > a:nth-child(1)", ) ) ) |