From f1ae37bb25463ece6597db42481b559f9ef91f33 Mon Sep 17 00:00:00 2001 From: Domenico Francesco Bruscino Date: Thu, 19 Feb 2026 15:21:03 +0100 Subject: [PATCH] ARTEMIS-5906 Fix console smoke tests on Firefox Firefox (GeckoDriver) strictly enforces that elements must be within the viewport before performing an Actions sequence. A simple .click() is more robust because the driver handles the scrolling logic internally. --- .../smoke/console/pages/ArtemisPage.java | 46 ++++++------------- .../tests/smoke/console/pages/LoginPage.java | 4 +- .../tests/smoke/console/pages/QueuePage.java | 4 +- .../tests/smoke/console/pages/QueuesPage.java | 8 ++-- .../smoke/console/pages/SendMessagePage.java | 12 ++--- .../console/pages/jmx/ArtemisTreePage.java | 10 ++-- .../console/pages/jmx/AttributesPage.java | 4 +- 7 files changed, 26 insertions(+), 62 deletions(-) diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/ArtemisPage.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/ArtemisPage.java index 8877fc13468..5e090301a5a 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/ArtemisPage.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/ArtemisPage.java @@ -25,7 +25,6 @@ import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.ADDRESSES_TAB; import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.ALERT_LOCATOR; @@ -57,17 +56,14 @@ public String getUser() { WebElement userDropdownMenuWebElement = driver.findElement(USER_DROPDOWN_MENU_LOCATOR); if (!logoutWebElement.isDisplayed()) { - Actions actions = new Actions(driver); - actions.moveToElement(userDropdownMenuWebElement).click().perform(); + userDropdownMenuWebElement.click(); } String logoutText = logoutWebElement.getText(); Pattern pattern = Pattern.compile("Logout \\(([^\\)]+)\\)"); Matcher matcher = pattern.matcher(logoutText); - Actions actions = new Actions(driver); - - actions.moveToElement(userDropdownMenuWebElement).click().perform(); + userDropdownMenuWebElement.click(); if (matcher.find()) { return matcher.group(1); @@ -79,9 +75,7 @@ public String getUser() { public AddressesPage getAddressesPage(int timeout) { WebElement queuesMenuItem = driver.findElement(ADDRESSES_TAB); - Actions actions = new Actions(driver); - - actions.moveToElement(queuesMenuItem).click().perform(); + queuesMenuItem.click(); return new AddressesPage(driver); } @@ -89,8 +83,7 @@ public AddressesPage getAddressesPage(int timeout) { public SendMessagePage getAddressSendMessagePage(String address, int timeout) { refresh(timeout); WebElement element = driver.findElement(ADDRESSES_TAB); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); List tdElements = driver.findElement(DATA_TABLE).findElement(By.xpath("//tr/td[contains(text(), '" + address + "')]")).findElement(By.xpath("./..")).findElements(TD_TAG_LOCATOR); tdElements.get(tdElements.size() - 1).findElement(BUTTON_LOCATOR).click(); @@ -106,8 +99,7 @@ public SendMessagePage getAddressSendMessagePage(String address, int timeout) { public SendMessagePage getQueueSendMessagePage(String queue, int timeout) { refresh(timeout); WebElement element = driver.findElement(QUEUES_TAB); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); List tdElements = driver.findElement(DATA_TABLE).findElement(By.xpath("//tr/td/a[contains(text(), '" + queue + "')]")).findElement(By.xpath("./../..")).findElements(By.tagName("td")); tdElements.get(tdElements.size() - 1).findElement(BUTTON_LOCATOR).click(); @@ -122,9 +114,7 @@ public SendMessagePage getQueueSendMessagePage(String queue, int timeout) { public QueuesPage getQueuesPage(int timeout) { WebElement queuesMenuItem = driver.findElement(QUEUES_TAB); - Actions actions = new Actions(driver); - - actions.moveToElement(queuesMenuItem).click().perform(); + queuesMenuItem.click(); waitForElementToBeVisible(QUEUES_TAB_SELECTED, timeout); @@ -148,9 +138,7 @@ public int getIndexOfColumn(String name) { public QueuesPage getQueuesPageFromMessageView(int timeout) { WebElement queuesMenuItem = driver.findElement(MESSAGE_VIEW_QUEUES_BUTTON); - Actions actions = new Actions(driver); - - actions.moveToElement(queuesMenuItem).click().perform(); + queuesMenuItem.click(); waitForElementToBeVisible(QUEUES_TAB_SELECTED, timeout); @@ -160,9 +148,7 @@ public QueuesPage getQueuesPageFromMessageView(int timeout) { public QueuesPage getQueuesPageFromMessagesView(int timeout) { WebElement queuesMenuItem = driver.findElement(MESSAGE_TABLE_QUEUES_BUTTON); - Actions actions = new Actions(driver); - - actions.moveToElement(queuesMenuItem).click().perform(); + queuesMenuItem.click(); waitForElementToBeVisible(QUEUES_TAB_SELECTED, timeout); @@ -171,30 +157,24 @@ public QueuesPage getQueuesPageFromMessagesView(int timeout) { public LoginPage logout(int timeout) { WebElement logoutWebElement = driver.findElement(LOGOUT_DROPDOWN_LOCATOR); - Actions actions = new Actions(driver); - actions.moveToElement(logoutWebElement).click().perform(); + logoutWebElement.click(); WebElement userDropdownMenuWebElement = logoutWebElement.findElement(LOGOUT_MENU_ITEM_LOCATOR); - actions = new Actions(driver); - - actions.moveToElement(userDropdownMenuWebElement).click().perform(); + userDropdownMenuWebElement.click(); return new LoginPage(driver); } public void enableColumn(String columnId) { WebElement element = driver.findElement(MANAGE_COLUMNS_BUTTON); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); element = driver.findElement(By.id("check-" + columnId)); - actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); element = driver.findElement(SAVE_BUTTON); - actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); } public Object postJolokiaExecRequest(String mbean, String operation, String arguments) { diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/LoginPage.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/LoginPage.java index 575d9c2c93e..1a50d5e115b 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/LoginPage.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/LoginPage.java @@ -19,7 +19,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.BRAND_LOCATOR; import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.LOGIN_BUTTON_LOCATOR; @@ -46,8 +45,7 @@ public StatusPage loginValidUser(String username, String password, int timeout) driver.findElement(USERNAME_LOCATOR).sendKeys(username); driver.findElement(PASSWORD_LOCATOR).sendKeys(password); WebElement element = driver.findElement(LOGIN_BUTTON_LOCATOR); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); waitForElementToBeVisible(LOGOUT_DROPDOWN_LOCATOR, timeout); waitForElementToBeVisible(By.xpath("//button/span[contains(text(),'Status')]"), timeout); diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/QueuePage.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/QueuePage.java index fca2c561827..b2dcb803077 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/QueuePage.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/QueuePage.java @@ -19,7 +19,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.A_TAG_LOCATOR; import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.COLUMN_MESSAGE_ID; @@ -39,8 +38,7 @@ public QueuePage(WebDriver driver) { public MessagePage getMessagePage(int index, int timeout) { int col = getIndexOfColumn(COLUMN_MESSAGE_ID); WebElement element = driver.findElement(TABLE_TAG_LOCATOR).findElements(TD_TAG_LOCATOR).get(col).findElement(A_TAG_LOCATOR); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); waitForElementToBeVisible(VIEW_MESSAGE_TITLE_LOCATOR, timeout); return new MessagePage(driver); diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/QueuesPage.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/QueuesPage.java index 0e98df9a988..adb8111311c 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/QueuesPage.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/QueuesPage.java @@ -19,7 +19,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; public class QueuesPage extends ArtemisPage { private static final String MESSAGE_COUNT_COLUMN_NAME = "Message Count"; @@ -36,8 +35,7 @@ public QueuePage getQueuePage(String name, int timeout) { WebElement messagesCountWebElement = queueRowWebElement.findElements(By.tagName("td")) .get(getIndexOfColumn(MESSAGE_COUNT_COLUMN_NAME)).findElement(By.tagName("a")); - Actions actions = new Actions(driver); - actions.moveToElement(messagesCountWebElement).click().perform(); + messagesCountWebElement.click(); waitForElementToBeVisible(QUEUES_PAGE_TITLE, timeout); return new QueuePage(driver); @@ -63,7 +61,7 @@ private By getQueueLocator(String name) { public boolean searchQueues(String queueNameInResults) { WebElement element = driver.findElement(SEARCH_BUTTON_LOCATOR); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); return countQueue(queueNameInResults) == 1; + element.click(); + return countQueue(queueNameInResults) == 1; } } diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/SendMessagePage.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/SendMessagePage.java index 00b4947a56c..cff3d8e5a99 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/SendMessagePage.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/SendMessagePage.java @@ -50,16 +50,14 @@ public boolean isUseCurrentLogonUserSelected() { public void selectUseCurrentLogonUser() { if (!isUseCurrentLogonUserSelected()) { WebElement element = driver.findElement(USE_LOGIN_LOCATOR); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); } } public void unselectUseCurrentLogonUser() { if (isUseCurrentLogonUserSelected()) { WebElement element = driver.findElement(USE_LOGIN_LOCATOR); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); } } @@ -76,10 +74,8 @@ public String getMessageText() { public void sendMessage() { WebElement element = driver.findElement(By.xpath("//button[contains(text(),'Send')]")); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); element = driver.findElement(By.xpath("//button[contains(text(),'Cancel')]")); - actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); } } diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/jmx/ArtemisTreePage.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/jmx/ArtemisTreePage.java index 7a7b9ae10e9..37872b86c28 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/jmx/ArtemisTreePage.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/jmx/ArtemisTreePage.java @@ -19,7 +19,6 @@ import org.apache.activemq.artemis.tests.smoke.console.pages.ConsolePage; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.BROKER_NODE_LOCATOR; import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.BROKER_BUTTON_LOCATOR; @@ -37,8 +36,7 @@ public ArtemisTreePage(WebDriver driver) { public void expandTree(int timeout) { waitForElementToBeVisible(EXPAND_BUTTON, timeout); WebElement element = driver.findElement(EXPAND_BUTTON); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); waitForElementToBeVisible(COLLAPSE_BUTTON, timeout); } @@ -46,8 +44,7 @@ public void expandTree(int timeout) { public void collapseTree(int timeout) { waitForElementToBeVisible(COLLAPSE_BUTTON, timeout); WebElement element = driver.findElement(COLLAPSE_BUTTON); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); waitForElementToBeVisible(EXPAND_BUTTON, timeout); } @@ -57,8 +54,7 @@ public String getNodeTitle() { public AttributesPage selectBrokerNode() { WebElement element = driver.findElement(BROKER_NODE_LOCATOR).findElement(BROKER_BUTTON_LOCATOR); - Actions actions = new Actions(driver); - actions.moveToElement(element).click().perform(); + element.click(); return new AttributesPage(driver); } } diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/jmx/AttributesPage.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/jmx/AttributesPage.java index 16f978d4f63..2b4bf66e7f6 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/jmx/AttributesPage.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/jmx/AttributesPage.java @@ -19,7 +19,6 @@ import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import java.util.Iterator; import java.util.List; @@ -42,8 +41,7 @@ public void selectAttribute(String name) { List cols = row.findElements(TD_TAG_LOCATOR); if (cols.size() == 2 && name.equals(cols.get(0).getText())) { ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", cols.get(0)); - Actions actions = new Actions(driver); - actions.moveToElement(cols.get(0)).click().perform(); + cols.get(0).click(); break; } }