Skip to content

Commit ffd5c3d

Browse files
authored
Wait for panel visibility in ShowAdminPage (#2620)
1 parent 435a498 commit ffd5c3d

2 files changed

Lines changed: 73 additions & 125 deletions

File tree

src/org/labkey/test/pages/ConfigureReportsAndScriptsPage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.labkey.test.util.LogMethod;
2828
import org.labkey.test.util.LoggedParam;
2929
import org.labkey.test.util.TestLogger;
30+
import org.openqa.selenium.WebDriver;
3031
import org.openqa.selenium.WebElement;
3132

3233
import java.io.File;
@@ -45,7 +46,7 @@ public class ConfigureReportsAndScriptsPage extends LabKeyPage
4546
private static final String DEFAULT_ENGINE = "Mozilla Rhino";
4647
private static final String EDIT_WINDOW_TITLE = "Edit Engine Configuration";
4748

48-
public ConfigureReportsAndScriptsPage(WebDriverWrapper test)
49+
public ConfigureReportsAndScriptsPage(WebDriver test)
4950
{
5051
super(test);
5152
waitForEnginesGrid();
@@ -54,7 +55,7 @@ public ConfigureReportsAndScriptsPage(WebDriverWrapper test)
5455
public static ConfigureReportsAndScriptsPage beginAt(WebDriverWrapper driver)
5556
{
5657
driver.beginAt(WebTestHelper.buildURL("core", "configureReportsAndScripts"));
57-
return new ConfigureReportsAndScriptsPage(driver);
58+
return new ConfigureReportsAndScriptsPage(driver.getDriver());
5859
}
5960

6061
public void waitForEnginesGrid()

src/org/labkey/test/pages/core/admin/ShowAdminPage.java

Lines changed: 70 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
import org.labkey.test.util.OptionalFeatureHelper;
2929
import org.openqa.selenium.WebDriver;
3030
import org.openqa.selenium.WebElement;
31+
import org.openqa.selenium.support.ui.ExpectedConditions;
3132

3233
import java.util.List;
34+
import java.util.function.Function;
3335

34-
// TODO: Missing lots of functionality
3536
public class ShowAdminPage extends LabKeyPage<ShowAdminPage.ElementCache>
3637
{
3738
public ShowAdminPage(WebDriver driver)
@@ -48,104 +49,105 @@ public static ShowAdminPage beginAt(WebDriverWrapper driver)
4849
public ShowAdminPage goToServerInformationSection()
4950
{
5051
elementCache().sectionServerInfo.click();
52+
shortWait().until(ExpectedConditions.visibilityOf(elementCache().serverInfoPanel));
5153
return this;
5254
}
5355

5456
public ShowAdminPage goToSettingsSection()
5557
{
5658
elementCache().sectionSettingsLinks.click();
59+
shortWait().until(ExpectedConditions.visibilityOf(elementCache().settingsPanel));
5760
return this;
5861
}
5962

6063
public ShowAdminPage goToModuleInformationSection()
6164
{
6265
elementCache().sectionModuleInfo.click();
66+
shortWait().until(ExpectedConditions.visibilityOf(elementCache().moduleInfoPanel));
6367
return this;
6468
}
6569

66-
public ShowAdminPage goToActiveUsersSection()
70+
public ShowAdminPage goToRecentUsersSection()
6771
{
6872
elementCache().sectionActiveUsers.click();
73+
shortWait().until(ExpectedConditions.visibilityOf(elementCache().recentUsersPanel));
6974
return this;
7075
}
7176

72-
public List<String> getActiveUsers()
77+
public void clickSettingsLink(String settingsLink)
7378
{
74-
goToActiveUsersSection();
75-
return getTexts(elementCache().findActiveUsers());
79+
goToSettingsSection();
80+
clickAndWait(Locator.linkWithText(settingsLink).findElement(elementCache().settingsPanel));
81+
}
82+
83+
public <T> T clickSettingsLink(String settingsLink, Function<WebDriver, T> pageFactory)
84+
{
85+
clickSettingsLink(settingsLink);
86+
return pageFactory.apply(getDriver());
87+
}
88+
89+
public List<String> getRecentUsers()
90+
{
91+
goToRecentUsersSection();
92+
return getTexts(elementCache().findRecentUsers());
7693
}
7794

7895
public String getServerGUID()
7996
{
8097
goToServerInformationSection();
81-
return elementCache().findServerGUID().getText();
98+
return elementCache().serverGuidEl.getText();
8299
}
83100

84101
public void clickAnalyticsSettings()
85102
{
86-
goToSettingsSection();
87-
clickAndWait(elementCache().analyticsSettingsLink);
103+
clickSettingsLink("analytics settings");
88104
}
89105

90106
public void clickAllowedExternalRedirectHosts()
91107
{
92-
goToSettingsSection();
93-
clickAndWait(elementCache().externalRedirectHostLink);
108+
clickSettingsLink("allowed external redirect hosts");
94109
Locator.waitForAnyElement(shortWait(), Locator.tagWithText("span", "Done"), Locator.tagWithText("span", "Save"));
95110
}
96111

97112
public ShowAuditLogPage clickAuditLog()
98113
{
99-
goToSettingsSection();
100-
clickAndWait(elementCache().auditLogLink);
101-
return new ShowAuditLogPage(getDriver());
114+
return clickSettingsLink("audit log", ShowAuditLogPage::new);
102115
}
103116

104117
public ExternalSourcesPage clickAllowedExternalResourceHosts()
105118
{
106-
goToSettingsSection();
107-
clickAndWait(elementCache().externalResourceHostsLink);
108-
return new ExternalSourcesPage(getDriver());
119+
return clickSettingsLink("allowed external resource hosts", ExternalSourcesPage::new);
109120
}
110121

111122
public AllowedFileExtensionAdminPage clickAllowedFileExtensions()
112123
{
113-
goToSettingsSection();
114-
clickAndWait(elementCache().allowedFileExtensionLink);
115-
return new AllowedFileExtensionAdminPage(getDriver());
124+
return clickSettingsLink("allowed file extensions", AllowedFileExtensionAdminPage::new);
116125
}
117126

118127
public void clickAuditLogMaintenance()
119128
{
120-
goToSettingsSection();
121-
clickAndWait(elementCache().auditLogMaintenanceLink);
129+
clickSettingsLink("Audit Log Maintenance");
122130
}
131+
123132
public LoginConfigurePage clickAuthentication()
124133
{
125-
goToSettingsSection();
126-
clickAndWait(elementCache().authenticationLink);
127-
return new LoginConfigurePage(getDriver());
134+
return clickSettingsLink("authentication", LoginConfigurePage::new);
128135
}
129136

130137
public void clickConfigurePageElements()
131138
{
132-
goToSettingsSection();
133-
clickAndWait(elementCache().configurePageElements);
139+
clickSettingsLink("configure page elements");
134140
Locator.waitForAnyElement(shortWait(), Locator.tagWithText("span", "Done"), Locator.tagWithText("span", "Save"));
135141
}
136142

137143
public ComplianceSettingsAccountsPage clickComplianceSettings()
138144
{
139-
goToSettingsSection();
140-
clickAndWait(elementCache().complianceSettings);
141-
return new ComplianceSettingsAccountsPage(getDriver());
145+
return clickSettingsLink("Compliance Settings", ComplianceSettingsAccountsPage::new);
142146
}
143147

144148
public DomainDesignerPage clickChangeUserProperties()
145149
{
146-
goToSettingsSection();
147-
clickAndWait(elementCache().changeUserPropertiesLink);
148-
return new DomainDesignerPage(getDriver());
150+
return clickSettingsLink("change user properties", DomainDesignerPage::new);
149151
}
150152

151153
public void clickDeprecatedFeatures()
@@ -156,130 +158,103 @@ public void clickDeprecatedFeatures()
156158

157159
public void clickEmailCustomization()
158160
{
159-
goToSettingsSection();
160-
clickAndWait(elementCache().emailCustomizationLink);
161+
clickSettingsLink("email customization");
161162
}
162163

163164
public void clickNotificationServiceAdmin()
164165
{
165-
goToSettingsSection();
166-
clickAndWait(elementCache().notificationServiceAdminLink);
166+
clickSettingsLink("notification service admin");
167167
}
168168

169169
public ConfigureFileSystemAccessPage clickFiles()
170170
{
171-
goToSettingsSection();
172-
clickAndWait(elementCache().filesLink);
173-
return new ConfigureFileSystemAccessPage(getDriver());
171+
return clickSettingsLink("files", ConfigureFileSystemAccessPage::new);
174172
}
175173

176174
public void clickFullTextSearch()
177175
{
178-
goToSettingsSection();
179-
clickAndWait(elementCache().fullTextSearchLink);
176+
clickSettingsLink("full-text search");
180177
}
181178

182179
public FolderTypePages clickFolderType()
183180
{
184-
goToSettingsSection();
185-
clickAndWait(elementCache().folderTypeLink);
186-
return new FolderTypePages(getDriver());
181+
return clickSettingsLink("folder types", FolderTypePages::new);
187182
}
188183

189184
public SiteValidationPage clickSiteValidation()
190185
{
191-
goToSettingsSection();
192-
clickAndWait(elementCache().siteValidationLink);
193-
return new SiteValidationPage(getDriver());
186+
return clickSettingsLink("site validation", SiteValidationPage::new);
194187
}
195188

196189
public LookAndFeelSettingsPage clickLookAndFeelSettings()
197190
{
198-
goToSettingsSection();
199-
clickAndWait(elementCache().lookAndFeelSettingsLink);
200-
return new LookAndFeelSettingsPage(getDriver());
191+
return clickSettingsLink("look and feel settings", LookAndFeelSettingsPage::new);
201192
}
202193

203194
public void clickMasterPatientIndex()
204195
{
205-
goToSettingsSection();
206-
clickAndWait(elementCache().masterPatientIndex);
196+
clickSettingsLink("Master Patient Index");
207197
}
208198

209199
public void clickProfiler()
210200
{
211-
goToSettingsSection();
212-
clickAndWait(elementCache().profilerLink);
201+
clickSettingsLink("profiler");
213202
}
214203

215204
public void clickRunningThreads()
216205
{
217-
goToSettingsSection();
218-
clickAndWait(elementCache().runningThreadsLink);
206+
clickSettingsLink("running threads");
219207
}
220208

221209
public CustomizeSitePage clickSiteSettings()
222210
{
223-
goToSettingsSection();
224-
clickAndWait(elementCache().siteSettingsLink);
225-
return new CustomizeSitePage(getDriver());
211+
return clickSettingsLink("site settings", CustomizeSitePage::new);
226212
}
227213

228214
public void clickSiteWideTerms()
229215
{
230-
goToSettingsSection();
231-
clickAndWait(elementCache().siteWideTermsLink);
216+
clickSettingsLink("site-wide terms of use");
232217
}
233218

234219
public ConfigureSystemMaintenancePage clickSystemMaintenance()
235220
{
236-
goToSettingsSection();
237-
clickAndWait(elementCache().systemMaintenanceLink);
238-
return new ConfigureSystemMaintenancePage(getDriver());
221+
return clickSettingsLink("system maintenance", ConfigureSystemMaintenancePage::new);
239222
}
240223

241224
public void clickSystemProperties()
242225
{
243-
goToSettingsSection();
244-
clickAndWait(elementCache().systemPropertiesLink);
226+
clickSettingsLink("system properties");
245227
}
246228

247229
public ConfigureReportsAndScriptsPage clickViewsAndScripting()
248230
{
249-
goToSettingsSection();
250-
clickAndWait(elementCache().viewsAndScriptingLink);
251-
return new ConfigureReportsAndScriptsPage(this);
231+
return clickSettingsLink("views and scripting", ConfigureReportsAndScriptsPage::new);
252232
}
253233

254234
public void clickCredits()
255235
{
256-
goToSettingsSection();
257-
clickAndWait(elementCache().creditsLink);
236+
clickSettingsLink("credits");
258237
}
259238

260239
public void clickViewPrimarySiteLogFile()
261240
{
262-
goToSettingsSection();
263-
clickAndWait(elementCache().viewPrimarySiteLogFileLink);
241+
clickSettingsLink("view primary site log file");
264242
}
265243

266244
public void clickPostgresActivity()
267245
{
268-
goToSettingsSection();
269-
clickAndWait(elementCache().postgresActivityLink);
246+
clickSettingsLink("postgres activity");
270247
}
271248

272249
public void clickPostgresLocks()
273250
{
274-
goToSettingsSection();
275-
clickAndWait(elementCache().postgresLocksLink);
251+
clickSettingsLink("postgres locks");
276252
}
277253

278254
public List<WebElement> getAllAdminConsoleLinks()
279255
{
280256
goToSettingsSection();
281-
WebElement adminLinksContainer = Locator.id("links").findElement(getDriver());
282-
return Locator.tag("a").findElements(adminLinksContainer);
257+
return Locator.tag("a").findElements(elementCache().settingsPanel);
283258
}
284259

285260
@Override
@@ -288,52 +263,24 @@ protected ElementCache newElementCache()
288263
return new ElementCache();
289264
}
290265

291-
protected class ElementCache extends LabKeyPage<?>.ElementCache
292-
{
293-
protected WebElement sectionServerInfo = Locator.linkWithText("Server Information").findWhenNeeded(this);
294-
protected WebElement sectionSettingsLinks = Locator.linkWithText("Settings").findWhenNeeded(this);
295-
protected WebElement sectionModuleInfo = Locator.linkWithText("Module Information").findWhenNeeded(this);
296-
protected WebElement sectionActiveUsers = Locator.linkWithText("Active Users").findWhenNeeded(this);
297-
298-
protected WebElement analyticsSettingsLink = Locator.linkWithText("analytics settings").findWhenNeeded(this);
299-
protected WebElement externalRedirectHostLink = Locator.linkWithText("allowed external redirect hosts").findWhenNeeded(this);
300-
protected WebElement externalResourceHostsLink = Locator.linkWithText("allowed external resource hosts").findWhenNeeded(this);
301-
protected WebElement allowedFileExtensionLink = Locator.linkWithText("allowed file extensions").findWhenNeeded(this);
302-
protected WebElement auditLogLink = Locator.linkWithText("audit log").findWhenNeeded(this);
303-
protected WebElement auditLogMaintenanceLink = Locator.linkWithText("Audit Log Maintenance").findWhenNeeded(this);
304-
protected WebElement authenticationLink = Locator.linkWithText("authentication").findWhenNeeded(this);
305-
protected WebElement configurePageElements = Locator.linkWithText("configure page elements").findWhenNeeded(this);
306-
protected WebElement complianceSettings = Locator.linkWithText("Compliance Settings").findWhenNeeded(this);
307-
protected WebElement changeUserPropertiesLink = Locator.linkWithText("change user properties").findWhenNeeded(this);
308-
protected WebElement emailCustomizationLink = Locator.linkWithText("email customization").findWhenNeeded(this);
309-
protected WebElement notificationServiceAdminLink = Locator.linkWithText("notification service admin").findWhenNeeded(this);
310-
protected WebElement filesLink = Locator.linkWithText("files").findWhenNeeded(this);
311-
protected WebElement fullTextSearchLink = Locator.linkWithText("full-text search").findWhenNeeded(this);
312-
protected WebElement folderTypeLink = Locator.linkWithText("folder types").findWhenNeeded(this);
313-
protected WebElement siteValidationLink = Locator.linkWithText("site validation").findWhenNeeded(this);
314-
protected WebElement lookAndFeelSettingsLink = Locator.linkWithText("look and feel settings").findWhenNeeded(this);
315-
protected WebElement masterPatientIndex = Locator.linkWithText("Master Patient Index").findWhenNeeded(this);
316-
protected WebElement profilerLink = Locator.linkWithText("profiler").findWhenNeeded(this);
317-
protected WebElement runningThreadsLink = Locator.linkWithText("running threads").findWhenNeeded(this);
318-
protected WebElement siteSettingsLink = Locator.linkWithText("site settings").findWhenNeeded(this);
319-
protected WebElement siteWideTermsLink = Locator.linkContainingText("site-wide terms of use").findWhenNeeded(this);
320-
protected WebElement systemMaintenanceLink = Locator.linkWithText("system maintenance").findWhenNeeded(this);
321-
protected WebElement systemPropertiesLink = Locator.linkContainingText("system properties").findWhenNeeded(this);
322-
protected WebElement viewsAndScriptingLink = Locator.linkWithText("views and scripting").findWhenNeeded(this);
323-
protected WebElement creditsLink = Locator.linkWithText("credits").findWhenNeeded(this);
324-
protected WebElement viewPrimarySiteLogFileLink = Locator.linkWithText("view primary site log file").findWhenNeeded(this);
325-
326-
protected WebElement postgresActivityLink = Locator.linkWithText("postgres activity").findWhenNeeded(this);
327-
protected WebElement postgresLocksLink = Locator.linkWithText("postgres locks").findWhenNeeded(this);
328-
329-
protected List<WebElement> findActiveUsers()
330-
{
331-
return Locator.tagWithName("table", "activeUsers").append(Locator.tag("td").position(1)).findElements(this);
332-
}
266+
protected class ElementCache extends LabKeyPage<ShowAdminPage.ElementCache>.ElementCache
267+
{
268+
private final WebElement adminNavPanel = Locator.id("lk-admin-nav").findWhenNeeded(this);
269+
private final WebElement sectionServerInfo = Locator.linkWithText("Server Information").findWhenNeeded(adminNavPanel);
270+
private final WebElement sectionSettingsLinks = Locator.linkWithText("Settings").findWhenNeeded(adminNavPanel);
271+
private final WebElement sectionModuleInfo = Locator.linkWithText("Module Information").findWhenNeeded(adminNavPanel);
272+
private final WebElement sectionActiveUsers = Locator.linkWithText("Active Users").findWhenNeeded(adminNavPanel);
333273

334-
protected WebElement findServerGUID()
274+
private final WebElement serverInfoPanel = Locator.id("info").withClass("lk-admin-section").findWhenNeeded(this);
275+
private final WebElement settingsPanel = Locator.id("links").withClass("lk-admin-section").findWhenNeeded(this);
276+
private final WebElement moduleInfoPanel = Locator.id("modules").withClass("lk-admin-section").findWhenNeeded(this);
277+
private final WebElement recentUsersPanel = Locator.id("users").withClass("lk-admin-section").findWhenNeeded(this);
278+
279+
private List<WebElement> findRecentUsers()
335280
{
336-
return Locator.tagWithText("td", "Server GUID").followingSibling("td").findElement(this);
281+
return Locator.tagWithName("table", "activeUsers").append(Locator.tag("td").position(1)).findElements(recentUsersPanel);
337282
}
283+
284+
private final WebElement serverGuidEl = Locator.tagWithText("td", "Server GUID").followingSibling("td").findWhenNeeded(serverInfoPanel);
338285
}
339286
}

0 commit comments

Comments
 (0)