Skip to content

Commit f1ae37b

Browse files
committed
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.
1 parent 30c8fc7 commit f1ae37b

7 files changed

Lines changed: 26 additions & 62 deletions

File tree

tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/ArtemisPage.java

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.openqa.selenium.JavascriptExecutor;
2626
import org.openqa.selenium.WebDriver;
2727
import org.openqa.selenium.WebElement;
28-
import org.openqa.selenium.interactions.Actions;
2928

3029
import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.ADDRESSES_TAB;
3130
import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.ALERT_LOCATOR;
@@ -57,17 +56,14 @@ public String getUser() {
5756
WebElement userDropdownMenuWebElement = driver.findElement(USER_DROPDOWN_MENU_LOCATOR);
5857

5958
if (!logoutWebElement.isDisplayed()) {
60-
Actions actions = new Actions(driver);
61-
actions.moveToElement(userDropdownMenuWebElement).click().perform();
59+
userDropdownMenuWebElement.click();
6260
}
6361

6462
String logoutText = logoutWebElement.getText();
6563
Pattern pattern = Pattern.compile("Logout \\(([^\\)]+)\\)");
6664
Matcher matcher = pattern.matcher(logoutText);
6765

68-
Actions actions = new Actions(driver);
69-
70-
actions.moveToElement(userDropdownMenuWebElement).click().perform();
66+
userDropdownMenuWebElement.click();
7167

7268
if (matcher.find()) {
7369
return matcher.group(1);
@@ -79,18 +75,15 @@ public String getUser() {
7975
public AddressesPage getAddressesPage(int timeout) {
8076
WebElement queuesMenuItem = driver.findElement(ADDRESSES_TAB);
8177

82-
Actions actions = new Actions(driver);
83-
84-
actions.moveToElement(queuesMenuItem).click().perform();
78+
queuesMenuItem.click();
8579

8680
return new AddressesPage(driver);
8781
}
8882

8983
public SendMessagePage getAddressSendMessagePage(String address, int timeout) {
9084
refresh(timeout);
9185
WebElement element = driver.findElement(ADDRESSES_TAB);
92-
Actions actions = new Actions(driver);
93-
actions.moveToElement(element).click().perform();
86+
element.click();
9487
List<WebElement> tdElements = driver.findElement(DATA_TABLE).findElement(By.xpath("//tr/td[contains(text(), '" + address + "')]")).findElement(By.xpath("./..")).findElements(TD_TAG_LOCATOR);
9588

9689
tdElements.get(tdElements.size() - 1).findElement(BUTTON_LOCATOR).click();
@@ -106,8 +99,7 @@ public SendMessagePage getAddressSendMessagePage(String address, int timeout) {
10699
public SendMessagePage getQueueSendMessagePage(String queue, int timeout) {
107100
refresh(timeout);
108101
WebElement element = driver.findElement(QUEUES_TAB);
109-
Actions actions = new Actions(driver);
110-
actions.moveToElement(element).click().perform();
102+
element.click();
111103
List<WebElement> tdElements = driver.findElement(DATA_TABLE).findElement(By.xpath("//tr/td/a[contains(text(), '" + queue + "')]")).findElement(By.xpath("./../..")).findElements(By.tagName("td"));
112104

113105
tdElements.get(tdElements.size() - 1).findElement(BUTTON_LOCATOR).click();
@@ -122,9 +114,7 @@ public SendMessagePage getQueueSendMessagePage(String queue, int timeout) {
122114
public QueuesPage getQueuesPage(int timeout) {
123115
WebElement queuesMenuItem = driver.findElement(QUEUES_TAB);
124116

125-
Actions actions = new Actions(driver);
126-
127-
actions.moveToElement(queuesMenuItem).click().perform();
117+
queuesMenuItem.click();
128118

129119
waitForElementToBeVisible(QUEUES_TAB_SELECTED, timeout);
130120

@@ -148,9 +138,7 @@ public int getIndexOfColumn(String name) {
148138
public QueuesPage getQueuesPageFromMessageView(int timeout) {
149139
WebElement queuesMenuItem = driver.findElement(MESSAGE_VIEW_QUEUES_BUTTON);
150140

151-
Actions actions = new Actions(driver);
152-
153-
actions.moveToElement(queuesMenuItem).click().perform();
141+
queuesMenuItem.click();
154142

155143
waitForElementToBeVisible(QUEUES_TAB_SELECTED, timeout);
156144

@@ -160,9 +148,7 @@ public QueuesPage getQueuesPageFromMessageView(int timeout) {
160148
public QueuesPage getQueuesPageFromMessagesView(int timeout) {
161149
WebElement queuesMenuItem = driver.findElement(MESSAGE_TABLE_QUEUES_BUTTON);
162150

163-
Actions actions = new Actions(driver);
164-
165-
actions.moveToElement(queuesMenuItem).click().perform();
151+
queuesMenuItem.click();
166152

167153
waitForElementToBeVisible(QUEUES_TAB_SELECTED, timeout);
168154

@@ -171,30 +157,24 @@ public QueuesPage getQueuesPageFromMessagesView(int timeout) {
171157

172158
public LoginPage logout(int timeout) {
173159
WebElement logoutWebElement = driver.findElement(LOGOUT_DROPDOWN_LOCATOR);
174-
Actions actions = new Actions(driver);
175160

176-
actions.moveToElement(logoutWebElement).click().perform();
161+
logoutWebElement.click();
177162
WebElement userDropdownMenuWebElement = logoutWebElement.findElement(LOGOUT_MENU_ITEM_LOCATOR);
178163

179-
actions = new Actions(driver);
180-
181-
actions.moveToElement(userDropdownMenuWebElement).click().perform();
164+
userDropdownMenuWebElement.click();
182165

183166
return new LoginPage(driver);
184167
}
185168

186169
public void enableColumn(String columnId) {
187170
WebElement element = driver.findElement(MANAGE_COLUMNS_BUTTON);
188-
Actions actions = new Actions(driver);
189-
actions.moveToElement(element).click().perform();
171+
element.click();
190172

191173
element = driver.findElement(By.id("check-" + columnId));
192-
actions = new Actions(driver);
193174

194-
actions.moveToElement(element).click().perform();
175+
element.click();
195176
element = driver.findElement(SAVE_BUTTON);
196-
actions = new Actions(driver);
197-
actions.moveToElement(element).click().perform();
177+
element.click();
198178
}
199179

200180
public Object postJolokiaExecRequest(String mbean, String operation, String arguments) {

tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/LoginPage.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.openqa.selenium.By;
2020
import org.openqa.selenium.WebDriver;
2121
import org.openqa.selenium.WebElement;
22-
import org.openqa.selenium.interactions.Actions;
2322

2423
import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.BRAND_LOCATOR;
2524
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)
4645
driver.findElement(USERNAME_LOCATOR).sendKeys(username);
4746
driver.findElement(PASSWORD_LOCATOR).sendKeys(password);
4847
WebElement element = driver.findElement(LOGIN_BUTTON_LOCATOR);
49-
Actions actions = new Actions(driver);
50-
actions.moveToElement(element).click().perform();
48+
element.click();
5149
waitForElementToBeVisible(LOGOUT_DROPDOWN_LOCATOR, timeout);
5250
waitForElementToBeVisible(By.xpath("//button/span[contains(text(),'Status')]"), timeout);
5351

tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/QueuePage.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.openqa.selenium.By;
2020
import org.openqa.selenium.WebDriver;
2121
import org.openqa.selenium.WebElement;
22-
import org.openqa.selenium.interactions.Actions;
2322

2423
import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.A_TAG_LOCATOR;
2524
import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.COLUMN_MESSAGE_ID;
@@ -39,8 +38,7 @@ public QueuePage(WebDriver driver) {
3938
public MessagePage getMessagePage(int index, int timeout) {
4039
int col = getIndexOfColumn(COLUMN_MESSAGE_ID);
4140
WebElement element = driver.findElement(TABLE_TAG_LOCATOR).findElements(TD_TAG_LOCATOR).get(col).findElement(A_TAG_LOCATOR);
42-
Actions actions = new Actions(driver);
43-
actions.moveToElement(element).click().perform();
41+
element.click();
4442
waitForElementToBeVisible(VIEW_MESSAGE_TITLE_LOCATOR, timeout);
4543

4644
return new MessagePage(driver);

tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/QueuesPage.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.openqa.selenium.By;
2020
import org.openqa.selenium.WebDriver;
2121
import org.openqa.selenium.WebElement;
22-
import org.openqa.selenium.interactions.Actions;
2322

2423
public class QueuesPage extends ArtemisPage {
2524
private static final String MESSAGE_COUNT_COLUMN_NAME = "Message Count";
@@ -36,8 +35,7 @@ public QueuePage getQueuePage(String name, int timeout) {
3635
WebElement messagesCountWebElement = queueRowWebElement.findElements(By.tagName("td"))
3736
.get(getIndexOfColumn(MESSAGE_COUNT_COLUMN_NAME)).findElement(By.tagName("a"));
3837

39-
Actions actions = new Actions(driver);
40-
actions.moveToElement(messagesCountWebElement).click().perform();
38+
messagesCountWebElement.click();
4139
waitForElementToBeVisible(QUEUES_PAGE_TITLE, timeout);
4240

4341
return new QueuePage(driver);
@@ -63,7 +61,7 @@ private By getQueueLocator(String name) {
6361

6462
public boolean searchQueues(String queueNameInResults) {
6563
WebElement element = driver.findElement(SEARCH_BUTTON_LOCATOR);
66-
Actions actions = new Actions(driver);
67-
actions.moveToElement(element).click().perform(); return countQueue(queueNameInResults) == 1;
64+
element.click();
65+
return countQueue(queueNameInResults) == 1;
6866
}
6967
}

tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/SendMessagePage.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,14 @@ public boolean isUseCurrentLogonUserSelected() {
5050
public void selectUseCurrentLogonUser() {
5151
if (!isUseCurrentLogonUserSelected()) {
5252
WebElement element = driver.findElement(USE_LOGIN_LOCATOR);
53-
Actions actions = new Actions(driver);
54-
actions.moveToElement(element).click().perform();
53+
element.click();
5554
}
5655
}
5756

5857
public void unselectUseCurrentLogonUser() {
5958
if (isUseCurrentLogonUserSelected()) {
6059
WebElement element = driver.findElement(USE_LOGIN_LOCATOR);
61-
Actions actions = new Actions(driver);
62-
actions.moveToElement(element).click().perform();
60+
element.click();
6361
}
6462
}
6563

@@ -76,10 +74,8 @@ public String getMessageText() {
7674

7775
public void sendMessage() {
7876
WebElement element = driver.findElement(By.xpath("//button[contains(text(),'Send')]"));
79-
Actions actions = new Actions(driver);
80-
actions.moveToElement(element).click().perform();
77+
element.click();
8178
element = driver.findElement(By.xpath("//button[contains(text(),'Cancel')]"));
82-
actions = new Actions(driver);
83-
actions.moveToElement(element).click().perform();
79+
element.click();
8480
}
8581
}

tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/jmx/ArtemisTreePage.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.apache.activemq.artemis.tests.smoke.console.pages.ConsolePage;
2020
import org.openqa.selenium.WebDriver;
2121
import org.openqa.selenium.WebElement;
22-
import org.openqa.selenium.interactions.Actions;
2322

2423
import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.BROKER_NODE_LOCATOR;
2524
import static org.apache.activemq.artemis.tests.smoke.console.PageConstants.BROKER_BUTTON_LOCATOR;
@@ -37,17 +36,15 @@ public ArtemisTreePage(WebDriver driver) {
3736
public void expandTree(int timeout) {
3837
waitForElementToBeVisible(EXPAND_BUTTON, timeout);
3938
WebElement element = driver.findElement(EXPAND_BUTTON);
40-
Actions actions = new Actions(driver);
41-
actions.moveToElement(element).click().perform();
39+
element.click();
4240
waitForElementToBeVisible(COLLAPSE_BUTTON, timeout);
4341
}
4442

4543

4644
public void collapseTree(int timeout) {
4745
waitForElementToBeVisible(COLLAPSE_BUTTON, timeout);
4846
WebElement element = driver.findElement(COLLAPSE_BUTTON);
49-
Actions actions = new Actions(driver);
50-
actions.moveToElement(element).click().perform();
47+
element.click();
5148
waitForElementToBeVisible(EXPAND_BUTTON, timeout);
5249
}
5350

@@ -57,8 +54,7 @@ public String getNodeTitle() {
5754

5855
public AttributesPage selectBrokerNode() {
5956
WebElement element = driver.findElement(BROKER_NODE_LOCATOR).findElement(BROKER_BUTTON_LOCATOR);
60-
Actions actions = new Actions(driver);
61-
actions.moveToElement(element).click().perform();
57+
element.click();
6258
return new AttributesPage(driver);
6359
}
6460
}

tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/console/pages/jmx/AttributesPage.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.openqa.selenium.JavascriptExecutor;
2020
import org.openqa.selenium.WebDriver;
2121
import org.openqa.selenium.WebElement;
22-
import org.openqa.selenium.interactions.Actions;
2322

2423
import java.util.Iterator;
2524
import java.util.List;
@@ -42,8 +41,7 @@ public void selectAttribute(String name) {
4241
List<WebElement> cols = row.findElements(TD_TAG_LOCATOR);
4342
if (cols.size() == 2 && name.equals(cols.get(0).getText())) {
4443
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", cols.get(0));
45-
Actions actions = new Actions(driver);
46-
actions.moveToElement(cols.get(0)).click().perform();
44+
cols.get(0).click();
4745
break;
4846
}
4947
}

0 commit comments

Comments
 (0)