From patchwork Fri Dec 15 11:24:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 36370 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 B25E7C4167B for ; Fri, 15 Dec 2023 11:24:38 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web11.60558.1702639475152572253 for ; Fri, 15 Dec 2023 03:24:35 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=rNeVBNES; 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 742759C3FCA for ; Fri, 15 Dec 2023 06:24:34 -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 UqHjcGM53YKM; Fri, 15 Dec 2023 06:24:33 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id E1BEF9C3A2F; Fri, 15 Dec 2023 06:24:33 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com E1BEF9C3A2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1702639473; bh=ocMDXJCX+2NnCMLA+RNg+vm7G73M6SbrXo9c6p20GRc=; h=From:To:Date:Message-Id:MIME-Version; b=rNeVBNESob0WPaIYsqyDNbzsVx2a9inXkj/23Fh+1UMh/bYicZ9e6XLhHpb8z59sy 7FgIZGeyoieqtsymnIzx/ChOs3Oy8NGX1+XzqF6Uo+CLm6BAfmQa/6Ir09eSscAXuf VprcRR0Iu6NDyo3fLSpvobbBiguOvZOO6Ci93uary3xuVBQbSqbF3rF+Ns76u+0XdR MH7V+SVibtK3ZOY5rb4EeMCTbPQE+Wl5A7NK8ypJRxNnf5OrPmSPvGAYtn6mW3iT3k tw4+9BI64tscSSxl8mViQ+sCgWAYAk7O79MDAql8qT7JHvhXCGoSgSxh6LVc/ibBii ZSDlJcq9+xBIQ== 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 r_4V9lxCz-Ca; Fri, 15 Dec 2023 06:24:33 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 282839C374B; Fri, 15 Dec 2023 06:24:32 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH 1/2] toaster/test: bug-fix element click intercepted in browser/test_layerdetails_page.py Date: Fri, 15 Dec 2023 12:24:23 +0100 Message-Id: <20231215112424.232168-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 ; Fri, 15 Dec 2023 11:24:38 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15687 selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted Signed-off-by: Alassane Yattara --- .../tests/browser/selenium_helpers_base.py | 29 ++++++++++++----- .../tests/browser/test_layerdetails_page.py | 31 +++++++++++++++---- 2 files changed, 46 insertions(+), 14 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..6d3e31e8f3 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py @@ -19,8 +19,8 @@ import os import time import unittest -import pytest 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 @@ -44,23 +44,22 @@ def create_selenium_driver(cls,browser='chrome'): try: return webdriver.Chrome(options=options) except SessionNotCreatedException as e: - exit_message = "Halting tests prematurely to avoid cascading errors." # check if chrome / chromedriver exists chrome_path = os.popen("find ~/.cache/selenium/chrome/ -name 'chrome' -type f -print -quit").read().strip() if not chrome_path: - pytest.exit(f"Failed to install/find chrome.\n{exit_message}") + raise SessionNotCreatedException("Failed to install/find chrome") chromedriver_path = os.popen("find ~/.cache/selenium/chromedriver/ -name 'chromedriver' -type f -print -quit").read().strip() if not chromedriver_path: - pytest.exit(f"Failed to install/find chromedriver.\n{exit_message}") + raise SessionNotCreatedException("Failed to install/find chromedriver") # check if depends on each are fulfilled depends_chrome = os.popen(f"ldd {chrome_path} | grep 'not found'").read().strip() if depends_chrome: - pytest.exit(f"Missing chrome dependencies.\n{depends_chrome}\n{exit_message}") + raise SessionNotCreatedException(f"Missing chrome dependencies\n{depends_chrome}") depends_chromedriver = os.popen(f"ldd {chromedriver_path} | grep 'not found'").read().strip() if depends_chromedriver: - pytest.exit(f"Missing chromedriver dependencies.\n{depends_chromedriver}\n{exit_message}") - # print original error otherwise - pytest.exit(f"Failed to start chromedriver.\n{e}\n{exit_message}") + raise SessionNotCreatedException(f"Missing chrome dependencies\n{depends_chromedriver}") + # raise original error otherwise + raise e elif browser == 'firefox': return webdriver.Firefox() elif browser == 'marionette': @@ -215,6 +214,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/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 @@ # 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 @@ -106,9 +107,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 +147,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 From patchwork Fri Dec 15 11:24:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 36369 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 AD762C41535 for ; Fri, 15 Dec 2023 11:24:38 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.60214.1702639475913698507 for ; Fri, 15 Dec 2023 03:24:36 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=C83mpsIT; 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 4E04E9C374B for ; Fri, 15 Dec 2023 06:24:35 -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 pLUCJ4wWgto3; Fri, 15 Dec 2023 06:24:34 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id DF4F49C3A2F; Fri, 15 Dec 2023 06:24:34 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com DF4F49C3A2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1702639474; bh=SGtttB+55Wge/WosFL8R6rPs4VMhDobvj13hlTAf6bg=; h=From:To:Date:Message-Id:MIME-Version; b=C83mpsITHvZ+1zkXlqN4NMsZMQ4jpwSjL/+fI7kg353g2W1brdmRGnIGsx8VqnntJ HqEmRlBorYsHiXlfQieSopR0HaboY4P3lkIyzUdGC/+1DfKknL6gpPsoEbBWrOg8/a dhyWrguB1D9PENvfdLX7DL9+LuhB4fm7Ix2nyR2FsBE/4dQL9Cabgq5px+Y57q0P8K ToLWSsrDjA838HYrJFoTwvcoH/WVwJ1RiqL7uJlbJ2fIKk4rX0/qqUpafECLYtXPZQ 86dAyDob1pRIHcpGaLi3AwZiiTSXAL0FcSMsG+ioo0aR3pCyJ9IrsQWjLNc7W0Tkn0 3pppKuEoifRzw== 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 xTVEwh5k3DFh; Fri, 15 Dec 2023 06:24:34 -0500 (EST) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 4522A9C374B; Fri, 15 Dec 2023 06:24:34 -0500 (EST) From: Alassane Yattara To: bitbake-devel@lists.openembedded.org Cc: Alassane Yattara Subject: [PATCH 2/2] toaster/test: Update tests/functional/functional_helpers test_functional_basic Date: Fri, 15 Dec 2023 12:24:24 +0100 Message-Id: <20231215112424.232168-2-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231215112424.232168-1-alassane.yattara@savoirfairelinux.com> References: <20231215112424.232168-1-alassane.yattara@savoirfairelinux.com> 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 ; Fri, 15 Dec 2023 11:24:38 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/15688 - Remove unused import time functional_helpers - Delay driver actions from test_functional_basic --- bitbake/lib/toaster/tests/functional/functional_helpers.py | 1 - .../lib/toaster/tests/functional/test_functional_basic.py | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bitbake/lib/toaster/tests/functional/functional_helpers.py b/bitbake/lib/toaster/tests/functional/functional_helpers.py index 6039d736e9..7c20437d14 100644 --- a/bitbake/lib/toaster/tests/functional/functional_helpers.py +++ b/bitbake/lib/toaster/tests/functional/functional_helpers.py @@ -11,7 +11,6 @@ import os import logging import subprocess import signal -import time import re from tests.browser.selenium_helpers_base import SeleniumTestCaseBase diff --git a/bitbake/lib/toaster/tests/functional/test_functional_basic.py b/bitbake/lib/toaster/tests/functional/test_functional_basic.py index 5d7a86bb9b..e48f13b003 100644 --- a/bitbake/lib/toaster/tests/functional/test_functional_basic.py +++ b/bitbake/lib/toaster/tests/functional/test_functional_basic.py @@ -89,6 +89,7 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase): # testcase (1516) def test_review_configuration_information(self): self.get('') + self.wait_until_visible('#global-nav') self.driver.find_element(By.XPATH, "//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() self.wait_until_visible('#projectstable') self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() @@ -134,6 +135,7 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase): # testcase (1517) def test_verify_machine_information(self): self.get('') + self.wait_until_visible('#global-nav') self.driver.find_element(By.XPATH, "//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() self.wait_until_visible('#projectstable') self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() @@ -152,6 +154,7 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase): # testcase (1518) def test_verify_most_built_recipes_information(self): self.get('') + self.wait_until_visible('#global-nav') self.driver.find_element(By.XPATH, "//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() self.wait_until_visible('#projectstable') self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() @@ -168,6 +171,7 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase): # testcase (1519) def test_verify_project_release_information(self): self.get('') + self.wait_until_visible('#global-nav') self.driver.find_element(By.XPATH, "//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() self.wait_until_visible('#projectstable') self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() @@ -181,6 +185,7 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase): # testcase (1520) def test_verify_layer_information(self): self.get('') + self.wait_until_visible('#global-nav') self.driver.find_element(By.XPATH, "//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() self.wait_until_visible('#projectstable') self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click() @@ -212,6 +217,7 @@ class FuntionalTestBasic(SeleniumFunctionalTestCase): # testcase (1521) def test_verify_project_detail_links(self): self.get('') + self.wait_until_visible('#global-nav') self.driver.find_element(By.XPATH, "//div[@id='global-nav']/ul/li/a[@href="+'"'+'/toastergui/projects/'+'"'+"]").click() self.wait_until_visible('#projectstable') self.find_element_by_link_text_in_table('projectstable', 'selenium-project').click()