From: Simon Brandhof Date: Thu, 9 Nov 2017 15:58:27 +0000 (+0100) Subject: Move pageobjects to new module sonar-qa-util X-Git-Tag: 7.0-RC1~339 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a7b805384a46f7a700d3917757899e251f2f8207;p=sonarqube.git Move pageobjects to new module sonar-qa-util --- diff --git a/server/pom.xml b/server/pom.xml index 99a700f2a58..5b27942fb00 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -23,6 +23,7 @@ sonar-ce sonar-plugin-bridge sonar-web + sonar-qa-util diff --git a/server/sonar-qa-util/pom.xml b/server/sonar-qa-util/pom.xml new file mode 100644 index 00000000000..a9534332a89 --- /dev/null +++ b/server/sonar-qa-util/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + org.sonarsource.sonarqube + server + 7.0-SNAPSHOT + .. + + sonar-qa-util + SonarQube :: Utilities for QA Tests + + + src/main/java/**/* + + + + + com.codeborne + selenide + 4.4.3 + + + org.assertj + assertj-core + + + org.sonarsource.orchestrator + sonar-orchestrator + ${orchestrator.version} + + + com.google.guava + guava + + 21.0 + + + + com.google.code.findbugs + jsr305 + provided + + + + diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SelenideConfig.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SelenideConfig.java new file mode 100644 index 00000000000..155ded5ee56 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/SelenideConfig.java @@ -0,0 +1,70 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util; + +import com.codeborne.selenide.Configuration; +import com.codeborne.selenide.WebDriverRunner; +import com.sonar.orchestrator.Orchestrator; +import java.util.stream.Collectors; +import org.openqa.selenium.WebDriver; + +import static java.util.Arrays.stream; + +public class SelenideConfig { + + private enum Browser { + firefox("(v46 and lower)"), + marionette("(recent Firefox, require Geckodriver)"), + chrome("(require Chromedriver)"); + + private final String label; + + Browser(String label) { + this.label = label; + } + + static Browser of(String s) { + try { + return Browser.valueOf(s); + } catch (Exception e) { + throw new IllegalArgumentException("Invalid browser: " + s + ". Supported values are " + + stream(values()).map(b -> b.name() + " " + b.label).collect(Collectors.joining(", "))); + } + } + } + + public static WebDriver configure(Orchestrator orchestrator) { + String browserKey = orchestrator.getConfiguration().getString("orchestrator.browser", Browser.firefox.name()); + Browser browser = Browser.of(browserKey); + Configuration.browser = browser.name(); + Configuration.baseUrl = orchestrator.getServer().getUrl(); + Configuration.timeout = 8_000; + Configuration.reportsFolder = "target/screenshots"; + Configuration.screenshots = true; + Configuration.captureJavascriptErrors = true; + Configuration.savePageSource = true; + Configuration.browserSize = "1280x1024"; + return getWebDriver(); + } + + static WebDriver getWebDriver() { + return WebDriverRunner.getWebDriver(); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/package-info.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/package-info.java new file mode 100644 index 00000000000..696f5531c1d --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonarqube.qa.util; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTaskItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTaskItem.java new file mode 100644 index 00000000000..0c86d3293b1 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTaskItem.java @@ -0,0 +1,65 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class BackgroundTaskItem { + + private final SelenideElement elt; + + public BackgroundTaskItem(SelenideElement elt) { + this.elt = elt; + } + + public SelenideElement getComponent() { + return elt.$("td:nth-child(2)"); + } + + public BackgroundTaskItem openActions() { + elt.$(".js-task-action > .dropdown-toggle").click(); + elt.$(".js-task-action > .dropdown-menu").shouldBe(Condition.visible); + return this; + } + + public BackgroundTaskItem openScannerContext() { + elt.$(".js-task-show-scanner-context").click(); + Selenide.$(".js-task-scanner-context").shouldBe(Condition.visible); + return this; + } + + public BackgroundTaskItem assertScannerContextContains(String text) { + Selenide.$(".js-task-scanner-context").should(Condition.hasText(text)); + return this; + } + + public BackgroundTaskItem openErrorStacktrace() { + elt.$(".js-task-show-stacktrace").click(); + Selenide.$(".js-task-stacktrace").shouldBe(Condition.visible); + return this; + } + + public BackgroundTaskItem assertErrorStacktraceContains(String text) { + Selenide.$(".js-task-stacktrace").should(Condition.hasText(text)); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTasksPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTasksPage.java new file mode 100644 index 00000000000..a14bc2cebff --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/BackgroundTasksPage.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.Selenide; +import java.util.List; +import java.util.stream.Collectors; +import org.openqa.selenium.By; + +public class BackgroundTasksPage { + + public BackgroundTasksPage() { + Selenide.$(By.cssSelector(".background-tasks")).should(Condition.exist); + } + + public ElementsCollection getTasks() { + return Selenide.$$(".background-tasks > tbody > tr"); + } + + public List getTasksAsItems() { + return getTasks() + .stream() + .map(BackgroundTaskItem::new) + .collect(Collectors.toList()); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EncryptionPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EncryptionPage.java new file mode 100644 index 00000000000..0e3bac79722 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/EncryptionPage.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class EncryptionPage extends Navigation { + + public EncryptionPage() { + Selenide.$("#encryption-page").should(Condition.exist); + } + + public SelenideElement generationForm() { + return Selenide.$("#generate-secret-key-form"); + } + + public SelenideElement newSecretKey() { + return Selenide.$("#secret-key"); + } + + public String encryptValue(String value) { + Selenide.$("#encryption-form-value").val(value); + Selenide.$("#encryption-form").submit(); + return Selenide.$("#encrypted-value").shouldBe(Condition.visible).val(); + } + + public EncryptionPage generateNewKey() { + Selenide.$("#encryption-new-key-form").submit(); + Selenide.$("#generate-secret-key-form").shouldBe(Condition.visible); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java new file mode 100644 index 00000000000..b210e01fb2e --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/LoginPage.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; +import org.openqa.selenium.By; + +public class LoginPage { + + public LoginPage() { + Selenide.$("#login_form").should(Condition.exist); + } + + public Navigation submitCredentials(String login) { + return submitCredentials(login, login, Navigation.class); + } + + public Navigation submitCredentials(String login, String password) { + return submitCredentials(login, password, Navigation.class); + } + + public Navigation useOAuth2() { + Selenide.$(".oauth-providers a").click(); + return Selenide.page(Navigation.class); + } + + public LoginPage submitWrongCredentials(String login, String password) { + Selenide.$("#login").val(login); + Selenide.$("#password").val(password); + Selenide.$(By.name("commit")).click(); + return Selenide.page(LoginPage.class); + } + + public SelenideElement getErrorMessage() { + return Selenide.$(".process-spinner-failed"); + } + + private T submitCredentials(String login, String password, Class expectedResultPage) { + Selenide.$("#login").val(login); + Selenide.$("#password").val(password); + Selenide.$(By.name("commit")).click(); + Selenide.$("#login").should(Condition.disappear); + return Selenide.page(expectedResultPage); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/MarketplacePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/MarketplacePage.java new file mode 100644 index 00000000000..908bad3b3e9 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/MarketplacePage.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class MarketplacePage { + + public MarketplacePage() { + Selenide.$("#marketplace-page").should(Condition.exist); + } + + public MarketplacePage hasPendingPlugins(String text) { + Selenide.$(".js-pending").should(Condition.exist).shouldHave(Condition.text(text)); + return this; + } + + public MarketplacePage hasPluginsCount(int count) { + Selenide.$$("#marketplace-plugins>ul>li").shouldHaveSize(count); + return this; + } + + public MarketplacePage hasPluginWithText(String name, String text) { + getPlugin(name).shouldHave(Condition.text(text)); + return this; + } + + public MarketplacePage searchPlugin(String search) { + Selenide.$("#marketplace-search input.search-box-input").should(Condition.exist).sendKeys(search); + return this; + } + + public MarketplacePage uninstallPlugin(String name) { + getPlugin(name).$("button.js-uninstall").click(); + return this; + } + + private SelenideElement getPlugin(String name) { + return Selenide.$$(".js-plugin-name").findBy(Condition.text(name)).should(Condition.exist).parent().parent().parent(); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java new file mode 100644 index 00000000000..67cea197772 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java @@ -0,0 +1,265 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.WebDriverRunner; +import com.sonar.orchestrator.Orchestrator; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.function.Consumer; +import javax.annotation.Nullable; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.html5.WebStorage; +import org.sonarqube.qa.util.SelenideConfig; +import org.sonarqube.qa.util.pageobjects.issues.IssuesPage; +import org.sonarqube.qa.util.pageobjects.measures.MeasuresPage; +import org.sonarqube.qa.util.pageobjects.organization.MembersPage; +import org.sonarqube.qa.util.pageobjects.projects.ProjectsPage; +import org.sonarqube.qa.util.pageobjects.settings.SettingsPage; + +public class Navigation { + + public Navigation() { + Selenide.$("#content").shouldBe(Condition.exist); + } + + public static Navigation create(Orchestrator orchestrator) { + WebDriver driver = SelenideConfig.configure(orchestrator); + driver.manage().deleteAllCookies(); + clearStorage(d -> d.getLocalStorage().clear()); + clearStorage(d -> d.getSessionStorage().clear()); + clearStorage(d -> Selenide.clearBrowserLocalStorage()); + return Selenide.open("/", Navigation.class); + } + + private static void clearStorage(Consumer cleaner) { + try { + cleaner.accept((WebStorage) WebDriverRunner.getWebDriver()); + } catch (Exception e) { + // ignore, it may occur when the first test opens browser. No pages are loaded + // and local/session storages are not available yet. + // Example with Chrome: "Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs." + } + } + + public Navigation openHome() { + return open("/", Navigation.class); + } + + public ProjectsPage openProjects() { + return open("/projects", ProjectsPage.class); + } + + public ProjectsPage openProjects(String organization) { + return open("/organizations/" + organization + "/projects", ProjectsPage.class); + } + + public ProjectsPage openProjectsWithQuery(String query) { + return open("/projects?" + query, ProjectsPage.class); + } + + public IssuesPage openIssues() { + return open("/issues", IssuesPage.class); + } + + public IssuesPage openIssues(String organization) { + return open("/organizations/" + organization + "/issues", IssuesPage.class); + } + + public IssuesPage openComponentIssues(String component) { + return open("/component_issues?id=" + component, IssuesPage.class); + } + + public ProjectDashboardPage openProjectDashboard(String projectKey) { + // TODO encode projectKey + String url = "/dashboard?id=" + projectKey; + return open(url, ProjectDashboardPage.class); + } + + public ProjectLinksPage openProjectLinks(String projectKey) { + // TODO encode projectKey + String url = "/project/links?id=" + projectKey; + return open(url, ProjectLinksPage.class); + } + + public QualityGatePage openQualityGates() { + String url = "/quality_gates"; + return open(url, QualityGatePage.class); + } + + public QualityGatePage openQualityGates(String organization) { + String url = "/organizations/" + organization + "/quality_gates"; + return open(url, QualityGatePage.class); + } + + public ProjectQualityGatePage openProjectQualityGate(String projectKey) { + // TODO encode projectKey + String url = "/project/quality_gate?id=" + projectKey; + return open(url, ProjectQualityGatePage.class); + } + + public ProjectKeyPage openProjectKey(String projectKey) { + // TODO encode projectKey + String url = "/project/key?id=" + projectKey; + return open(url, ProjectKeyPage.class); + } + + public ProjectActivityPage openProjectActivity(String projectKey) { + // TODO encode projectKey + String url = "/project/activity?id=" + projectKey; + return open(url, ProjectActivityPage.class); + } + + public MeasuresPage openProjectMeasures(String projectKey) { + // TODO encode projectKey + String url = "/component_measures?id=" + projectKey; + return open(url, MeasuresPage.class); + } + + public ProjectCodePage openCode(String projectKey) { + // TODO encode projectKey + String url = "/code?id=" + projectKey; + return open(url, ProjectCodePage.class); + } + + public ProjectCodePage openCode(String projectKey, String selected) { + // TODO encode projectKey and selected + String url = "/code?id=" + projectKey + "&selected=" + selected; + return open(url, ProjectCodePage.class); + } + + public MembersPage openOrganizationMembers(String orgKey) { + String url = "/organizations/" + orgKey + "/members"; + return open(url, MembersPage.class); + } + + public QualityProfilePage openQualityProfile(String language, String name, String organization) { + String profileUrl = "/quality_profiles/show?language=" + language + "&name=" + name; + return open("/organizations/" + organization + profileUrl, QualityProfilePage.class); + } + + public BackgroundTasksPage openBackgroundTasksPage() { + return open("/background_tasks", BackgroundTasksPage.class); + } + + public SettingsPage openSettings(@Nullable String projectKey) throws UnsupportedEncodingException { + String url = projectKey != null ? "/project/settings?id=" + URLEncoder.encode(projectKey, "UTF-8") : "/settings"; + return open(url, SettingsPage.class); + } + + public EncryptionPage openEncryption() { + return open("/settings/encryption", EncryptionPage.class); + } + + public SystemInfoPage openSystemInfo() { + return open("/admin/system", SystemInfoPage.class); + } + + public MarketplacePage openMarketplace() { + return open("/admin/marketplace", MarketplacePage.class); + } + + public NotificationsPage openNotifications() { + return open("/account/notifications", NotificationsPage.class); + } + + public ProjectPermissionsPage openProjectPermissions(String projectKey) { + String url = "/project_roles?id=" + projectKey; + return open(url, ProjectPermissionsPage.class); + } + + public ProjectsManagementPage openProjectsManagement() { + return open("/projects_admin", ProjectsManagementPage.class); + } + + public LoginPage openLogin() { + return open("/sessions/login", LoginPage.class); + } + + public void open(String relativeUrl) { + Selenide.open(relativeUrl); + } + + public

P open(String relativeUrl, Class

pageObjectClassClass) { + return Selenide.open(relativeUrl, pageObjectClassClass); + } + + public Navigation shouldBeLoggedIn() { + loggedInDropdown().should(Condition.visible); + return this; + } + + public Navigation shouldNotBeLoggedIn() { + logInLink().should(Condition.visible); + return this; + } + + public LoginPage logIn() { + logInLink().click(); + return Selenide.page(LoginPage.class); + } + + public Navigation logOut() { + SelenideElement dropdown = loggedInDropdown(); + // click must be on the but not on the dropdown

  • + // for compatibility with phantomjs + dropdown.find(".dropdown-toggle").click(); + dropdown.find(By.linkText("Log out")).click(); + return this; + } + + public RulesPage openRules() { + return open("/coding_rules", RulesPage.class); + } + + public SelenideElement clickOnQualityProfiles() { + return Selenide.$(By.linkText("Quality Profiles")); + } + + public SelenideElement getRightBar() { + return Selenide.$("#global-navigation .navbar-right"); + } + + public SelenideElement getFooter() { + return Selenide.$("#footer"); + } + + public SelenideElement getErrorMessage() { + return Selenide.$("#error"); + } + + private SelenideElement logInLink() { + return Selenide.$(By.linkText("Log in")); + } + + private SelenideElement loggedInDropdown() { + return Selenide.$(".js-user-authenticated"); + } + + public Navigation shouldBeRedirectedToLogin() { + Selenide.$("#login_form").should(Condition.visible); + return this; + } + +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/NotificationsPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/NotificationsPage.java new file mode 100644 index 00000000000..bd4911a94c6 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/NotificationsPage.java @@ -0,0 +1,118 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; + +public class NotificationsPage extends Navigation { + + private final String EMAIL = "EmailNotificationChannel"; + + public NotificationsPage() { + Selenide.$("#account-page").shouldHave(Condition.text("Overall notifications")); + } + + public NotificationsPage shouldHaveGlobalNotification(String type) { + return shouldHaveGlobalNotification(type, EMAIL); + } + + public NotificationsPage shouldHaveGlobalNotification(String type, String channel) { + return shouldBeChecked(globalCheckboxSelector(type, channel)); + } + + public NotificationsPage shouldNotHaveGlobalNotification(String type) { + return shouldNotHaveGlobalNotification(type, EMAIL); + } + + public NotificationsPage shouldNotHaveGlobalNotification(String type, String channel) { + return shouldNotBeChecked(globalCheckboxSelector(type, channel)); + } + + public NotificationsPage shouldHaveProjectNotification(String project, String type, String channel) { + return shouldBeChecked(projectCheckboxSelector(project, type, channel)); + } + + public NotificationsPage shouldNotHaveProjectNotification(String project, String type, String channel) { + return shouldNotBeChecked(projectCheckboxSelector(project, type, channel)); + } + + public NotificationsPage addGlobalNotification(String type) { + return addGlobalNotification(type, EMAIL); + } + + public NotificationsPage addGlobalNotification(String type, String channel) { + shouldNotHaveGlobalNotification(type, channel); + toggleCheckbox(globalCheckboxSelector(type, channel)); + shouldHaveGlobalNotification(type, channel); + return this; + } + + public NotificationsPage removeGlobalNotification(String type) { + return removeGlobalNotification(type, EMAIL); + } + + public NotificationsPage removeGlobalNotification(String type, String channel) { + shouldHaveGlobalNotification(type, channel); + toggleCheckbox(globalCheckboxSelector(type, channel)); + shouldNotHaveGlobalNotification(type, channel); + return this; + } + + public NotificationsPage addProjectNotification(String project, String type, String channel) { + shouldNotHaveProjectNotification(project, type, channel); + toggleCheckbox(projectCheckboxSelector(project, type, channel)); + shouldHaveProjectNotification(project, type, channel); + return this; + } + + public NotificationsPage removeProjectNotification(String project, String type, String channel) { + shouldHaveProjectNotification(project, type, channel); + toggleCheckbox(projectCheckboxSelector(project, type, channel)); + shouldNotHaveProjectNotification(project, type, channel); + return this; + } + + private String globalCheckboxSelector(String type, String channel) { + return "#global-notification-" + type + "-" + channel; + } + + private String projectCheckboxSelector(String project, String type, String channel) { + return "#project-notification-" + project + "-" + type + "-" + channel; + } + + private NotificationsPage shouldBeChecked(String selector) { + Selenide.$(selector) + .shouldBe(Condition.visible) + .shouldHave(Condition.cssClass("icon-checkbox-checked")); + return this; + } + + private NotificationsPage shouldNotBeChecked(String selector) { + Selenide.$(selector) + .shouldBe(Condition.visible) + .shouldNotHave(Condition.cssClass("icon-checkbox-checked")); + return this; + } + + private void toggleCheckbox(String selector) { + Selenide.$(selector).click(); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectActivityPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectActivityPage.java new file mode 100644 index 00000000000..ad8206cd47d --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectActivityPage.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.Selenide; +import java.util.List; +import java.util.stream.Collectors; + +public class ProjectActivityPage { + + public ProjectActivityPage() { + Selenide.$("#project-activity").should(Condition.exist); + } + + public ElementsCollection getAnalyses() { + return Selenide.$$(".project-activity-analysis"); + } + + public List getAnalysesAsItems() { + return getAnalyses() + .stream() + .map(ProjectAnalysisItem::new) + .collect(Collectors.toList()); + } + + public ProjectAnalysisItem getLastAnalysis() { + return new ProjectAnalysisItem(Selenide.$(".project-activity-analysis")); + } + + public ProjectAnalysisItem getFirstAnalysis() { + return new ProjectAnalysisItem(Selenide.$$(".project-activity-analysis").last()); + } + + public ProjectActivityPage assertFirstAnalysisOfTheDayHasText(String day, String text) { + Selenide.$("#project-activity") + .find(".project-activity-day[data-day=\"" + day + "\"]") + .find(".project-activity-analysis") + .should(Condition.hasText(text)); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectAnalysisItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectAnalysisItem.java new file mode 100644 index 00000000000..2f6d4449c4d --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectAnalysisItem.java @@ -0,0 +1,102 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class ProjectAnalysisItem { + + private final SelenideElement elt; + + public ProjectAnalysisItem(SelenideElement elt) { + this.elt = elt; + } + + public ProjectAnalysisItem shouldHaveEventWithText(String text) { + elt.find(".project-activity-events").shouldHave(Condition.text(text)); + return this; + } + + public ProjectAnalysisItem shouldHaveDeleteButton() { + elt.find(".js-analysis-actions").click(); + elt.find(".js-delete-analysis").shouldBe(Condition.visible); + return this; + } + + public ProjectAnalysisItem shouldNotHaveDeleteButton() { + elt.find(".js-analysis-actions").click(); + elt.find(".js-delete-analysis").shouldNotBe(Condition.visible); + return this; + } + + public void delete() { + elt.find(".js-analysis-actions").click(); + elt.find(".js-delete-analysis").click(); + + SelenideElement modal = Selenide.$(".modal"); + modal.shouldBe(Condition.visible); + modal.find("button[type=\"submit\"]").click(); + + elt.shouldNotBe(Condition.visible); + } + + public ProjectAnalysisItem addCustomEvent(String name) { + elt.find(".js-analysis-actions").click(); + elt.find(".js-add-event").click(); + + SelenideElement modal = Selenide.$(".modal"); + modal.shouldBe(Condition.visible); + modal.find("input").setValue(name); + modal.find("button[type=\"submit\"]").click(); + + elt.find(".project-activity-event:first-child").shouldHave(Condition.text(name)); + return this; + } + + public ProjectAnalysisItem changeFirstEvent(String newName) { + SelenideElement firstEvent = elt.find(".project-activity-event:first-child"); + firstEvent.find(".js-change-event").click(); + + SelenideElement modal = Selenide.$(".modal"); + modal.shouldBe(Condition.visible); + modal.find("input").setValue(newName); + modal.find("button[type=\"submit\"]").click(); + + firstEvent.shouldHave(Condition.text(newName)); + return this; + } + + public ProjectAnalysisItem deleteFirstEvent() { + int eventsCount = elt.findAll(".project-activity-event").size(); + + SelenideElement firstEvent = elt.find(".project-activity-event:first-child"); + firstEvent.find(".js-delete-event").click(); + + SelenideElement modal = Selenide.$(".modal"); + modal.shouldBe(Condition.visible); + modal.find("button[type=\"submit\"]").click(); + + elt.findAll(".project-activity-event").shouldHaveSize(eventsCount - 1); + + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java new file mode 100644 index 00000000000..42bb86748a2 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; + +public class ProjectCodePage { + + public ProjectCodePage() { + } + + public ProjectCodePage openFirstComponent() { + Selenide.$$(".code-name-cell a").first().click(); + return this; + } + + public ProjectCodePage search(String query) { + Selenide.$(".code-search .search-box-input").val(query); + return this; + } + + public ProjectCodePage shouldHaveComponent(String name) { + Selenide.$(".code-components").shouldHave(Condition.text(name)); + return this; + } + + public ProjectCodePage shouldHaveCode(String code) { + Selenide.$(".code-components .source-viewer").shouldHave(Condition.text(code)); + return this; + } + + public ProjectCodePage shouldHaveBreadcrumbs(String... breadcrumbs) { + for (String breadcrumb : breadcrumbs) { + Selenide.$(".code-breadcrumbs").shouldHave(Condition.text(breadcrumb)); + } + return this; + } + + public ProjectCodePage shouldSearchResult(String name) { + Selenide.$(".code-search-with-results").shouldHave(Condition.text(name)); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectDashboardPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectDashboardPage.java new file mode 100644 index 00000000000..4db286489dd --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectDashboardPage.java @@ -0,0 +1,107 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; +import java.util.Arrays; +import org.openqa.selenium.By; + +import static org.assertj.core.api.Assertions.assertThat; + + +public class ProjectDashboardPage { + + public ProjectDashboardPage() { + Selenide.$(".overview").shouldBe(Condition.visible); + } + + public SelenideElement getLinesOfCode() { + SelenideElement element = Selenide.$("#overview-ncloc"); + element.shouldBe(Condition.visible); + return element; + } + + public SelenideElement getLanguageDistribution() { + SelenideElement element = Selenide.$("#overview-language-distribution"); + element.shouldBe(Condition.visible); + return element; + } + + public SelenideElement getOverviewMeasure(String measure) { + ElementsCollection measures = Selenide.$$(".overview-domain-measure"); + SelenideElement element = measures.find(Condition.text(measure)).shouldBe(Condition.visible); + return element; + } + + private SelenideElement getTagsMeta() { + SelenideElement element = Selenide.$(".overview-meta-tags"); + element.shouldBe(Condition.visible); + return element; + } + + public ProjectDashboardPage shouldHaveTags(String... tags) { + String tagsList = String.join(", ", Arrays.asList(tags)); + this.getTagsMeta().$(".tags-list > span").should(Condition.hasText(tagsList)); + return this; + } + + public ProjectDashboardPage shouldNotBeEditable() { + SelenideElement tagsElem = this.getTagsMeta(); + tagsElem.$("button").shouldNot(Condition.exist); + tagsElem.$("div.multi-select").shouldNot(Condition.exist); + return this; + } + + public ProjectDashboardPage shouldBeEditable() { + SelenideElement tagsElem = this.getTagsMeta(); + tagsElem.$("button").shouldBe(Condition.visible); + return this; + } + + public ProjectDashboardPage openTagEditor() { + SelenideElement tagsElem = this.getTagsMeta(); + tagsElem.$("button").shouldBe(Condition.visible).click(); + tagsElem.$("div.multi-select").shouldBe(Condition.visible); + return this; + } + + public SelenideElement getTagAtIdx(Integer idx) { + SelenideElement tagsElem = this.getTagsMeta(); + tagsElem.$("div.multi-select").shouldBe(Condition.visible); + return tagsElem.$$("ul.menu a").get(idx); + } + + public ProjectDashboardPage sendKeysToTagsInput(CharSequence... charSequences) { + SelenideElement tagsInput = this.getTagsMeta().find("input"); + tagsInput.sendKeys(charSequences); + return this; + } + + public ProjectDashboardPage hasQualityGateLink(String name, String link) { + SelenideElement elem = Selenide.$$(".overview-meta-card") + .findBy(Condition.text("Quality Gate")).should(Condition.exist) + .find(By.linkText(name)).should(Condition.exist); + assertThat(elem.attr("href")).endsWith(link); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectKeyPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectKeyPage.java new file mode 100644 index 00000000000..5a3e5ec678b --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectKeyPage.java @@ -0,0 +1,100 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class ProjectKeyPage { + + public ProjectKeyPage() { + Selenide.$("#project-key").should(Condition.exist); + } + + public ProjectKeyPage assertSimpleUpdate() { + Selenide.$("#update-key-new-key").shouldBe(Condition.visible); + Selenide.$("#update-key-submit").shouldBe(Condition.visible); + return this; + } + + public ProjectKeyPage trySimpleUpdate(String newKey) { + Selenide.$("#update-key-new-key").val(newKey); + Selenide.$("#update-key-submit").click(); + Selenide.$("#update-key-confirm").click(); + return this; + } + + public ProjectKeyPage openFineGrainedUpdate() { + Selenide.$("#update-key-tab-fine").click(); + Selenide.$("#project-key-fine-grained-update").shouldBe(Condition.visible); + return this; + } + + public ProjectKeyPage tryFineGrainedUpdate(String key, String newKey) { + SelenideElement form = Selenide.$(".js-fine-grained-update[data-key=\"" + key + "\"]"); + form.shouldBe(Condition.visible); + + form.$("input").val(newKey); + form.$("button").click(); + + Selenide.$("#update-key-confirm").click(); + return this; + } + + public ProjectKeyPage assertBulkChange() { + Selenide.$("#bulk-update-replace").shouldBe(Condition.visible); + Selenide.$("#bulk-update-by").shouldBe(Condition.visible); + Selenide.$("#bulk-update-see-results").shouldBe(Condition.visible); + return this; + } + + public ProjectKeyPage simulateBulkChange(String replace, String by) { + Selenide.$("#bulk-update-replace").val(replace); + Selenide.$("#bulk-update-by").val(by); + Selenide.$("#bulk-update-see-results").click(); + + Selenide.$("#bulk-update-simulation").shouldBe(Condition.visible); + return this; + } + + public ProjectKeyPage assertBulkChangeSimulationResult(String oldKey, String newKey) { + SelenideElement row = Selenide.$("#bulk-update-results").$("[data-key=\"" + oldKey + "\"]"); + row.$(".js-old-key").should(Condition.hasText(oldKey)); + row.$(".js-new-key").should(Condition.hasText(newKey)); + return this; + } + + public ProjectKeyPage assertDuplicated(String oldKey) { + SelenideElement row = Selenide.$("#bulk-update-results").$("[data-key=\"" + oldKey + "\"]"); + row.$(".js-new-key").$(".badge-danger").shouldBe(Condition.visible); + return this; + } + + public ProjectKeyPage confirmBulkUpdate() { + Selenide.$("#bulk-update-confirm").click(); + return this; + } + + public ProjectKeyPage assertSuccessfulBulkUpdate() { + Selenide.$("#project-key-bulk-update").$(".alert.alert-success").shouldBe(Condition.visible); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinkItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinkItem.java new file mode 100644 index 00000000000..7444ca554ac --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinkItem.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.SelenideElement; +import org.openqa.selenium.NoSuchElementException; + +public class ProjectLinkItem { + + private final SelenideElement elt; + + public ProjectLinkItem(SelenideElement elt) { + this.elt = elt; + } + + public SelenideElement getName() { + return elt.$(".js-name"); + } + + public SelenideElement getType() { + try { + return elt.$(".js-type"); + } catch (NoSuchElementException e) { + return null; + } + } + + public SelenideElement getUrl() { + return elt.$(".js-url"); + } + + public SelenideElement getDeleteButton() { + return elt.$(".js-delete-button"); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinksPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinksPage.java new file mode 100644 index 00000000000..8f9e8860f5a --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectLinksPage.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.Selenide; +import java.util.List; +import java.util.stream.Collectors; + +public class ProjectLinksPage { + + public ProjectLinksPage() { + Selenide.$("#project-links").should(Condition.exist); + } + + public ElementsCollection getLinks() { + return Selenide.$$("#project-links tr[data-name]"); + } + + public List getLinksAsItems() { + return getLinks() + .stream() + .map(ProjectLinkItem::new) + .collect(Collectors.toList()); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectPermissionsPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectPermissionsPage.java new file mode 100644 index 00000000000..0fabc151b7d --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectPermissionsPage.java @@ -0,0 +1,59 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; + +public class ProjectPermissionsPage { + + public ProjectPermissionsPage() { + Selenide.$("#project-permissions-page").should(Condition.exist); + } + + public ProjectPermissionsPage shouldBePublic() { + Selenide.$("#visibility-public .icon-radio.is-checked").shouldBe(Condition.visible); + return this; + } + + public ProjectPermissionsPage shouldBePrivate() { + Selenide.$("#visibility-private .icon-radio.is-checked").shouldBe(Condition.visible); + return this; + } + + public ProjectPermissionsPage turnToPublic() { + Selenide.$("#visibility-public").click(); + Selenide.$("#confirm-turn-to-public").click(); + shouldBePublic(); + return this; + } + + public ProjectPermissionsPage turnToPrivate() { + Selenide.$("#visibility-private").click(); + shouldBePrivate(); + return this; + } + + public ProjectPermissionsPage shouldNotAllowPrivate() { + Selenide.$("#visibility-private").shouldHave(Condition.cssClass("text-muted")); + Selenide.$(".upgrade-organization-box").shouldBe(Condition.visible); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectQualityGatePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectQualityGatePage.java new file mode 100644 index 00000000000..0cf3904c640 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectQualityGatePage.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class ProjectQualityGatePage { + + public ProjectQualityGatePage() { + Selenide.$("#project-quality-gate").should(Condition.exist); + } + + public SelenideElement getSelectedQualityGate() { + return Selenide.$(".Select-value-label"); + } + + public void assertNotSelected() { + Selenide.$(".Select-placeholder").should(Condition.exist); + Selenide.$(".Select-value-label").shouldNot(Condition.exist); + } + + public void setQualityGate(String name) { + Selenide.$(".Select-input input").val(name).pressEnter(); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectsManagementPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectsManagementPage.java new file mode 100644 index 00000000000..529c98abb25 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectsManagementPage.java @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; + +public class ProjectsManagementPage { + + public ProjectsManagementPage() { + Selenide.$("#projects-management-page").should(Condition.exist); + } + + public ProjectsManagementPage shouldHaveProjectsCount(int count) { + Selenide.$$("#projects-management-page-projects tbody tr").shouldHaveSize(count); + return this; + } + + public ProjectsManagementPage shouldHaveProject(String key) { + Selenide.$("#projects-management-page-projects").shouldHave(Condition.text(key)); + return this; + } + + public ProjectsManagementPage createProject(String key, String name, String visibility) { + Selenide.$("#create-project").click(); + Selenide.$("#create-project-name").val(key); + Selenide.$("#create-project-key").val(name); + Selenide.$("#visibility-" + visibility).click(); + Selenide.$("#create-project-submit").submit(); + return this; + } + + public ProjectsManagementPage bulkApplyPermissionTemplate(String template) { + Selenide.$(".js-bulk-apply-permission-template").click(); + Selenide.$(".modal .Select-value").click(); + Selenide.$$(".modal .Select-option").findBy(Condition.text(template)).click(); + Selenide.$(".modal-foot button").click(); + Selenide.$(".modal-body .alert-success").shouldBe(Condition.visible); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityGatePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityGatePage.java new file mode 100644 index 00000000000..2f8f1669123 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityGatePage.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; + +public class QualityGatePage { + public QualityGatePage() { + Selenide.$("#quality-gates-page").shouldBe(Condition.visible); + } + + public QualityGatePage countQualityGates(Integer count) { + Selenide.$$("#quality-gates-page .list-group-item").shouldHaveSize(count); + return this; + } + + public QualityGatePage canCreateQG() { + Selenide.$("#quality-gate-add").should(Condition.exist).shouldBe(Condition.visible); + return this; + } + + public QualityGatePage canNotCreateQG() { + Selenide.$("#quality-gate-add").shouldNot(Condition.exist); + return this; + } + + public QualityGatePage displayIntro() { + Selenide.$(".search-navigator-intro").should(Condition.exist).shouldBe(Condition.visible); + return this; + } + + public QualityGatePage displayQualityGateDetail(String qualityGateName) { + Selenide.$(".layout-page-main-header").shouldHave(Condition.text(qualityGateName)); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityProfilePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityProfilePage.java new file mode 100644 index 00000000000..88b009687b0 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/QualityProfilePage.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; + +public class QualityProfilePage { + public QualityProfilePage() { + Selenide.$("#quality-profile").shouldBe(Condition.visible); + } + + public QualityProfilePage shouldHaveMissingSonarWayRules(Integer nbRules) { + Selenide.$(".quality-profile-rules-sonarway-missing") + .shouldBe(Condition.visible) + .$("a").shouldHave(Condition.text(nbRules.toString())); + return this; + } + + public RulesPage showMissingSonarWayRules() { + Selenide.$(".quality-profile-rules-sonarway-missing") + .shouldBe(Condition.visible).$("a").click(); + Selenide.$(".coding-rules").shouldBe(Condition.visible); + return Selenide.page(RulesPage.class); + } + + public QualityProfilePage shouldHaveAssociatedProject(String projectName) { + Selenide.$(".js-profile-project").shouldHave(Condition.text(projectName)); + return this; + } + + public QualityProfilePage shouldAllowToChangeProjects() { + Selenide.$(".js-change-projects").shouldBe(Condition.visible).click(); + Selenide.$("#profile-projects .select-list-list").shouldBe(Condition.visible); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleDetails.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleDetails.java new file mode 100644 index 00000000000..035a66f3019 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleDetails.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class RuleDetails { + + private final SelenideElement elt; + + public RuleDetails(SelenideElement elt) { + this.elt = elt; + } + + public RuleDetails shouldBeActivatedOn(String profileName) { + Selenide.$("#coding-rules-detail-quality-profiles").shouldHave(Condition.text(profileName)); + return this; + } + +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleItem.java new file mode 100644 index 00000000000..7b5d818bc25 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RuleItem.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.SelenideElement; + +public class RuleItem { + + private final SelenideElement elt; + + public RuleItem(SelenideElement elt) { + this.elt = elt; + } + + public SelenideElement getTitle() { + return elt.$(".coding-rule-title"); + } + + public SelenideElement getMetadata() { + return elt.$(".coding-rule-meta"); + } + + +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RulesPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RulesPage.java new file mode 100644 index 00000000000..6b2916e5240 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/RulesPage.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; +import org.openqa.selenium.By; + +public class RulesPage extends Navigation { + + public RulesPage() { + Selenide.$(By.cssSelector(".coding-rules")).should(Condition.exist); + } + + public int getTotal() { + // warning - number is localized + return Integer.parseInt(Selenide.$("#coding-rules-total").text()); + } + + public ElementsCollection getSelectedFacetItems(String facetName) { + SelenideElement facet = Selenide.$(".search-navigator-facet-box[data-property='"+ facetName+"']").shouldBe(Condition.visible); + return facet.$$(".js-facet.active"); + } + + public RulesPage shouldHaveTotalRules(Integer total) { + Selenide.$("#coding-rules-total").shouldHave(Condition.text(total.toString())); + return this; + } + + public RulesPage openFacet(String facet) { + Selenide.$(".search-navigator-facet-box[data-property=\"" + facet + "\"] .js-facet-toggle").click(); + return this; + } + + public RulesPage selectFacetItemByText(String facet, String itemText) { + Selenide.$$(".search-navigator-facet-box[data-property=\"" + facet + "\"] .js-facet") + .findBy(Condition.text(itemText)).click(); + return this; + } + + public RuleDetails openFirstRule() { + Selenide.$$(".js-rule").first().click(); + Selenide.$(".coding-rules-details").shouldBe(Condition.visible); + return new RuleDetails(Selenide.$(".coding-rules-details")); + } + +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPage.java new file mode 100644 index 00000000000..5b93e2b457a --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPage.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.CollectionCondition; +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class SystemInfoPage { + public SystemInfoPage() { + Selenide.$(".page-title").should(Condition.exist).shouldHave(Condition.text("System Info")); + } + + public SystemInfoPage shouldHaveCard(String title) { + Selenide.$$(".system-info-health-card-title").find(Condition.text(title)).should(Condition.exist); + return this; + } + + public SystemInfoPage shouldHaveCards(String... titles) { + Selenide.$$(".system-info-health-card-title").shouldHave(CollectionCondition.texts(titles)); + return this; + } + + public SystemInfoPageItem getCardItem(String card) { + SelenideElement cardTitle = Selenide.$$(".system-info-health-card-title").find(Condition.text(card)).should(Condition.exist); + return new SystemInfoPageItem(cardTitle.parent().parent()); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPageItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPageItem.java new file mode 100644 index 00000000000..55d9c84092e --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SystemInfoPageItem.java @@ -0,0 +1,85 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; + +public class SystemInfoPageItem { + private final SelenideElement elt; + + public SystemInfoPageItem(SelenideElement elt) { + this.elt = elt; + } + + public SystemInfoPageItem shouldHaveHealth() { + elt.$(".system-info-health-info .status-indicator").should(Condition.exist); + return this; + } + + public SystemInfoPageItem shouldHaveSection(String section) { + ensureOpen(); + elt.$$("h4").findBy(Condition.text(section)).should(Condition.exist); + return this; + } + + public SystemInfoPageItem shouldNotHaveSection(String section) { + ensureOpen(); + elt.$$("h4").findBy(Condition.text(section)).shouldNot(Condition.exist); + return this; + } + + public SystemInfoPageItem shouldHaveMainSection() { + ensureOpen(); + elt.$$(".system-info-section").get(0).find("h4").shouldNot(Condition.exist); + return this; + } + + public SystemInfoPageItem shouldHaveField(String field) { + ensureOpen(); + elt.$$(".system-info-section-item-name").findBy(Condition.text(field)).should(Condition.exist); + return this; + } + + public SystemInfoPageItem shouldNotHaveField(String field) { + ensureOpen(); + elt.$$(".system-info-section-item-name").findBy(Condition.exactText(field)).shouldNot(Condition.exist); + return this; + } + + public SystemInfoPageItem shouldHaveFieldWithValue(String field, String value) { + ensureOpen(); + SelenideElement fieldElem = elt.$$(".system-info-section-item-name").findBy(Condition.text(field)).should(Condition.exist); + fieldElem.parent().parent().$$("td").shouldHaveSize(2).get(1).shouldHave(Condition.text(value)); + return this; + } + + public SystemInfoPageItem ensureOpen() { + if(!isOpen()) { + elt.click(); + elt.$(".boxed-group-inner").should(Condition.exist); + } + return this; + } + + private boolean isOpen() { + return elt.$(".boxed-group-inner").exists(); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/Issue.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/Issue.java new file mode 100644 index 00000000000..d4e2713112e --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/Issue.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects.issues; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class Issue { + + private final SelenideElement elt; + + public Issue(SelenideElement elt) { + this.elt = elt; + } + + public Issue shouldAllowAssign() { + elt.find(".js-issue-assign").shouldBe(Condition.visible); + return this; + } + + public Issue shouldAllowChangeType() { + elt.find(".js-issue-set-type").shouldBe(Condition.visible); + return this; + } + + public Issue shouldNotAllowAssign() { + elt.find(".js-issue-assign").shouldNotBe(Condition.visible); + return this; + } + + public Issue shouldNotAllowChangeType() { + elt.find(".js-issue-set-type").shouldNotBe(Condition.visible); + return this; + } + + public Issue assigneeSearchResultCount(String query, Integer count) { + SelenideElement assignLink = elt.find(".js-issue-assign"); + assignLink.click(); + SelenideElement popupMenu = Selenide.$(".bubble-popup ul.menu").shouldBe(Condition.visible); + Selenide.$(".bubble-popup input.search-box-input").shouldBe(Condition.visible).val("").sendKeys(query); + popupMenu.$("li a[data-text='Not assigned']").shouldNot(Condition.exist); + popupMenu.$$("li").shouldHaveSize(count); + assignLink.click(); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/IssuesPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/IssuesPage.java new file mode 100644 index 00000000000..92755921f37 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/issues/IssuesPage.java @@ -0,0 +1,82 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects.issues; + +import com.codeborne.selenide.CollectionCondition; +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.Selenide; +import java.util.List; +import java.util.stream.Collectors; + +public class IssuesPage { + + public IssuesPage() { + Selenide.$(".issues").should(Condition.exist); + } + + private ElementsCollection getIssuesElements() { + return Selenide.$$(".issues .issue"); + } + + private ElementsCollection getIssuesPathComponents() { + return Selenide.$$(".issues-workspace-list-component"); + } + + public List getIssues() { + return getIssuesElements() + .stream() + .map(Issue::new) + .collect(Collectors.toList()); + } + + public IssuesPage issuesCount(Integer count) { + this.getIssuesElements().shouldHaveSize(count); + return this; + } + + public Issue getFirstIssue() { + getIssuesElements().shouldHave(CollectionCondition.sizeGreaterThan(0)); + return new Issue(getIssuesElements().first()); + } + + public IssuesPage componentsShouldContain(String path) { + this.getIssuesPathComponents().forEach(element -> element.shouldHave(Condition.text(path))); + return this; + } + + public IssuesPage componentsShouldNotContain(String path) { + this.getIssuesPathComponents().forEach(element -> element.shouldNotHave(Condition.text(path))); + return this; + } + + public IssuesPage bulkChangeOpen() { + Selenide.$("#issues-bulk-change").shouldBe(Condition.visible).click(); + Selenide.$("#bulk-change-form").shouldBe(Condition.visible); + return this; + } + + public IssuesPage bulkChangeAssigneeSearchCount(String query, Integer count) { + Selenide.$("#issues-bulk-change-assignee .Select-input input").val(query); + Selenide.$$("#issues-bulk-change-assignee .Select-option").shouldHaveSize(count); + Selenide.$("#issues-bulk-change-assignee .Select-input input").pressEscape(); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasureContent.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasureContent.java new file mode 100644 index 00000000000..4f3da0472e5 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasureContent.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects.measures; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.SelenideElement; + +public class MeasureContent { + private final SelenideElement elt; + + public MeasureContent(SelenideElement elt) { + this.elt = elt; + } + + public MeasureContent shouldHaveTitle(String title) { + this.elt.$(".measure-details-header .measure-details-metric").should(Condition.exist).shouldHave(Condition.text(title)); + return this; + } + + public MeasureContent shouldHaveHeaderValue(String value) { + this.elt.$(".measure-details-header .measure-details-value").should(Condition.exist).shouldHave(Condition.text(value)); + return this; + } + + public MeasureContent shouldHaveFile(String path) { + this.getFiles().find(Condition.text(path)).should(Condition.exist); + return this; + } + + public MeasureContent drillDown(String item) { + this.getFiles().find(Condition.text(item)).should(Condition.exist).find("a").click(); + return this; + } + + public MeasureContent shouldDisplayCode() { + this.elt.$(".source-line-code").should(Condition.exist); + return this; + } + + private ElementsCollection getFiles() { + return this.elt.$$(".measure-details-component-row"); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java new file mode 100644 index 00000000000..de052a403de --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java @@ -0,0 +1,97 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects.measures; + +import com.codeborne.selenide.CollectionCondition; +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; +import org.openqa.selenium.Keys; + +public class MeasuresPage { + public MeasuresPage() { + Selenide.$("#component-measures").should(Condition.exist); + } + + public MeasuresPage displayBubbleChart(String title) { + SelenideElement bubblechart = Selenide.$("#component-measures .measure-overview-bubble-chart"); + bubblechart.$(".measure-overview-bubble-chart-title").shouldHave(Condition.text(title)); + return this; + } + + public MeasuresPage measureHasValue(String measure, Integer value) { + SelenideElement sidebar = this.getSideBar(); + sidebar.$("#measure-" + measure + "-name").should(Condition.exist); + sidebar.$("#measure-" + measure + "-value").should(Condition.exist).shouldHave(Condition.text(value.toString())); + return this; + } + + public MeasuresPage measureHasLeak(String measure, Integer value) { + SelenideElement sidebar = this.getSideBar(); + sidebar.$("#measure-" + measure + "-name").should(Condition.exist); + sidebar.$("#measure-" + measure + "-leak").should(Condition.exist).shouldHave(Condition.text(value.toString())); + return this; + } + + public MeasuresPage breadcrumbsShouldHave(String item) { + Selenide.$(".layout-page-header-panel .measure-breadcrumbs").shouldHave(Condition.text(item)); + return this; + } + + public MeasuresPage breadcrumbsShouldNotHave(String item) { + Selenide.$(".layout-page-header-panel .measure-breadcrumbs").shouldNotHave(Condition.text(item)); + return this; + } + + public MeasuresPage backShortcut() { + Selenide.$(".layout-page-header-panel").sendKeys(Keys.LEFT); + return this; + } + + public MeasuresPage switchView(String view) { + SelenideElement select = Selenide.$(".measure-view-select").should(Condition.exist); + select.click(); + select.$(".Select-menu-outer").should(Condition.exist) + .$$(".Select-option").shouldHave(CollectionCondition.sizeGreaterThan(1)) + .find(Condition.text(view)).should(Condition.exist).click(); + return this; + } + + public MeasuresPage openFacet(String facet) { + SelenideElement facetBox = Selenide.$$(".search-navigator-facet-box").find(Condition.text(facet)); + if(!facetBox.find("search-navigator-facet-list").isDisplayed()) { + facetBox.$(".search-navigator-facet-header a").should(Condition.exist).click(); + } + return this; + } + + public MeasureContent openMeasureContent(String measure) { + SelenideElement sidebar = this.getSideBar(); + SelenideElement facetItem = sidebar.$("#measure-" + measure + "-name"); + facetItem.click(); + MeasureContent content = new MeasureContent(Selenide.$("#component-measures .measure-details-content").should(Condition.exist)); + content.shouldHaveTitle(facetItem.getText()); + return content; + } + + private SelenideElement getSideBar() { + return Selenide.$("#component-measures .layout-page-side").should(Condition.exist); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MemberItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MemberItem.java new file mode 100644 index 00000000000..fd02dfb1f11 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MemberItem.java @@ -0,0 +1,94 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonarqube.qa.util.pageobjects.organization; + +import com.codeborne.selenide.CollectionCondition; +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class MemberItem { + private final SelenideElement elt; + + public MemberItem(SelenideElement elt) { + this.elt = elt; + } + + public MemberItem shouldBeNamed(String login, String name) { + ElementsCollection tds = this.elt.$$("td"); + tds.get(1).$("strong").shouldHave(Condition.text(name)); + tds.get(1).$("span").shouldHave(Condition.text(login)); + return this; + } + + public MemberItem shouldHaveGroups(Integer groups) { + ElementsCollection tds = this.elt.$$("td"); + tds.get(2).should(Condition.exist); + tds.get(2).shouldHave(Condition.text(groups.toString())); + return this; + } + + public MemberItem shouldNotHaveActions() { + this.elt.$$("td").shouldHave(CollectionCondition.sizeLessThan(3)); + return this; + } + + public MemberItem removeMembership() { + ElementsCollection tds = this.elt.$$("td"); + tds.shouldHave(CollectionCondition.sizeGreaterThan(3)); + SelenideElement actionTd = tds.get(3); + actionTd.$("button").should(Condition.exist).click(); + actionTd.$$(".dropdown-menu > li").get(2).shouldBe(Condition.visible).click(); + SelenideElement modal = getModal("Remove user"); + modal.$("button.button-red").shouldBe(Condition.visible).click(); + return this; + } + + public MemberItem manageGroupsOpen() { + ElementsCollection tds = this.elt.$$("td"); + tds.shouldHave(CollectionCondition.sizeGreaterThan(3)); + SelenideElement actionTd = tds.get(3); + actionTd.$("button").should(Condition.exist).click(); + actionTd.$$(".dropdown-menu > li").get(0).shouldBe(Condition.visible).click(); + getModal("Manage groups"); + return this; + } + + public MemberItem manageGroupsSelect(String group) { + SelenideElement modal = getModal("Manage groups"); + modal.$$("li").find(Condition.text(group)).shouldBe(Condition.visible).click(); + return this; + } + + public MemberItem manageGroupsSave() { + SelenideElement modal = getModal("Manage groups"); + modal.$("button[type='submit']").shouldBe(Condition.visible).click(); + return this; + } + + private SelenideElement getModal(String title) { + Selenide.$(".modal-head").should(Condition.exist).shouldHave(Condition.text(title)); + SelenideElement form = Selenide.$(".ReactModalPortal form"); + form.should(Condition.exist); + return form; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MembersPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MembersPage.java new file mode 100644 index 00000000000..21816aea1c1 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/organization/MembersPage.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonarqube.qa.util.pageobjects.organization; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; + +public class MembersPage { + + public MembersPage() { + Selenide.$(".navbar-tabs a.active").shouldBe(Condition.visible).shouldHave(Condition.text("Members")); + } + + public ElementsCollection getMembers() { + return Selenide.$$("table.data tr"); + } + + public MemberItem getMembersByIdx(Integer idx) { + return new MemberItem(getMembers().get(idx)); + } + + public MembersPage shouldHaveTotal(int total) { + Selenide.$(".panel-vertical > span > strong").shouldHave(Condition.text(String.valueOf(total))); + return this; + } + + public MembersPage searchForMember(String query) { + Selenide.$(".page .search-box-input").shouldBe(Condition.visible).val("").sendKeys(query); + return this; + } + + public MembersPage canAddMember() { + Selenide.$(".page-actions").shouldBe(Condition.visible); + return this; + } + + public MembersPage canNotAddMember() { + Selenide.$(".page-actions").shouldNot(Condition.exist); + return this; + } + + public MembersPage addMember(String login) { + this.canAddMember(); + Selenide.$(".page-actions button").click(); + + SelenideElement modal = this.getModal("Add user"); + SelenideElement input = modal.$(".Select-input input"); + input.val(login); + modal.$("div.Select-option.is-focused").should(Condition.exist); + input.pressEnter(); + modal.$("button[type='submit']").click(); + return this; + } + + private SelenideElement getModal(String title) { + Selenide.$(".modal-head").should(Condition.exist).shouldHave(Condition.text(title)); + SelenideElement form = Selenide.$(".ReactModalPortal form"); + form.should(Condition.exist); + return form; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/package-info.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/package-info.java new file mode 100644 index 00000000000..bc9f94356e3 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonarqube.qa.util.pageobjects; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/FacetItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/FacetItem.java new file mode 100644 index 00000000000..74425419c26 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/FacetItem.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects.projects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; + +public class FacetItem { + + private final SelenideElement elt; + + public FacetItem(SelenideElement elt) { + this.elt = elt; + } + + public FacetItem shouldHaveValue(String key, String value) { + this.elt.$(".facet[data-key=\"" + key + "\"] .facet-stat").shouldHave(Condition.text(value)); + return this; + } + + public void selectValue(String key) { + this.elt.$(".facet[data-key=\"" + key + "\"]").click(); + } + + public FacetItem selectOptionItem(String value) { + SelenideElement selectInput = this.elt.$(".Select-input input"); + selectInput.val(value); + this.elt.$("div.Select-option.is-focused").should(Condition.exist); + selectInput.pressEnter(); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectItem.java new file mode 100644 index 00000000000..45ef2cb62ec --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectItem.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects.projects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; + +public class ProjectItem { + + private final SelenideElement elt; + + public ProjectItem(SelenideElement elt) { + this.elt = elt; + } + + public ProjectItem shouldHaveMeasure(String metricKey, String value) { + this.elt.$(".project-card-measure[data-key=\"" + metricKey + "\"]").shouldHave(Condition.text(value)); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectsPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectsPage.java new file mode 100644 index 00000000000..cc55ce2d619 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/projects/ProjectsPage.java @@ -0,0 +1,116 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects.projects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.WebDriverRunner; +import org.assertj.core.api.Assertions; + +public class ProjectsPage { + + public ProjectsPage() { + Selenide.$("#projects-page").shouldBe(Condition.visible); + } + + public ElementsCollection getProjects() { + return Selenide.$$(".projects-list > .boxed-group"); + } + + public ElementsCollection getFacets() { + return Selenide.$$(".search-navigator-facet-box"); + } + + public ProjectItem getProjectByKey(String projectKey) { + SelenideElement element = getProjects().find(Condition.attribute("data-key", projectKey)); + return new ProjectItem(element); + } + + public ProjectItem getProjectByIdx(Integer idx) { + return new ProjectItem(getProjects().get(idx)); + } + + public FacetItem getFacetByProperty(String facetProperty) { + SelenideElement element = getFacets().find(Condition.attribute("data-key", facetProperty)); + return new FacetItem(element); + } + + public ProjectsPage shouldHaveTotal(int total) { + // warning - number is localized + Selenide.$("#projects-total").shouldHave(Condition.text(String.valueOf(total))); + return this; + } + + public ProjectsPage shouldDisplayAllProjects() { + Assertions.assertThat(WebDriverRunner.url()).endsWith("/projects"); + return this; + } + + public ProjectsPage shouldDisplayAllProjectsWidthSort(String sort) { + Assertions.assertThat(WebDriverRunner.url()).endsWith("/projects?sort=" + sort); + return this; + } + + public ProjectsPage shouldDisplayFavoriteProjects() { + Assertions.assertThat(WebDriverRunner.url()).endsWith("/projects/favorite"); + return this; + } + + public ProjectsPage selectAllProjects() { + Selenide.$("#all-projects").click(); + return shouldDisplayAllProjects(); + } + + public ProjectsPage selectFavoriteProjects() { + Selenide.$("#favorite-projects").click(); + return shouldDisplayFavoriteProjects(); + } + + public ProjectsPage searchProject(String search) { + SelenideElement searchInput = Selenide.$(".projects-topbar-item-search input"); + searchInput.setValue("").sendKeys(search); + return this; + } + + public ProjectsPage changePerspective(String perspective) { + SelenideElement sortSelect = getOpenTopBar().$(".js-projects-perspective-select"); + sortSelect.$(".Select-value").should(Condition.exist).click(); + sortSelect.$(".Select-option[title='" + perspective + "']").should(Condition.exist).click(); + return this; + } + + public ProjectsPage sortProjects(String sort) { + SelenideElement sortSelect = getOpenTopBar().$(".js-projects-sorting-select"); + sortSelect.$(".Select-value").should(Condition.exist).click(); + sortSelect.$(".Select-option[title='" + sort + "']").should(Condition.exist).click(); + return this; + } + + public ProjectsPage invertSorting() { + getOpenTopBar().$(".js-projects-sorting-invert").should(Condition.exist).click(); + return this; + } + + private SelenideElement getOpenTopBar() { + return Selenide.$(".projects-topbar-items").should(Condition.exist); + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/PropertySetInput.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/PropertySetInput.java new file mode 100644 index 00000000000..fb5de082a9c --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/PropertySetInput.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects.settings; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; + +public class PropertySetInput { + + private final SelenideElement elt; + + public PropertySetInput(SelenideElement elt) { + this.elt = elt; + } + + public PropertySetInput setFieldValue(int index, String fieldKey, String value) { + elt.findAll("input[name$=\"[" + fieldKey + "]\"]").get(index).val(value); + return this; + } + + public PropertySetInput setFieldValue(String fieldKey, String value) { + return setFieldValue(0, fieldKey, value); + } + + public PropertySetInput save() { + elt.find(".js-save-changes").click(); + elt.find(".js-save-changes").shouldNot(Condition.exist); + return this; + } +} diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/SettingsPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/SettingsPage.java new file mode 100644 index 00000000000..1bc4e646d5d --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/SettingsPage.java @@ -0,0 +1,80 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects.settings; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.Selenide; +import com.codeborne.selenide.SelenideElement; +import org.openqa.selenium.By; + +public class SettingsPage { + + public SettingsPage() { + Selenide.$("#settings-page").shouldBe(Condition.visible); + } + + public SettingsPage assertMenuContains(String categoryName) { + Selenide.$(".side-tabs-menu").$(By.linkText(categoryName)).shouldBe(Condition.visible); + return this; + } + + public SettingsPage assertSettingDisplayed(String settingKey) { + Selenide.$(".settings-definition[data-key='" + settingKey + "']").shouldBe(Condition.visible); + return this; + } + + public SettingsPage assertSettingNotDisplayed(String settingKey) { + Selenide.$(".settings-definition[data-key='" + settingKey + "']").shouldNotBe(Condition.visible); + return this; + } + + public SettingsPage openCategory(String categoryName) { + Selenide.$(".side-tabs-menu").$(By.linkText(categoryName)).click(); + return this; + } + + public SettingsPage assertStringSettingValue(String settingKey, String value) { + Selenide.$("input[name=\"settings[" + settingKey + "]\"]").shouldHave(Condition.exactValue(value)); + return this; + } + + public SettingsPage assertBooleanSettingValue(String settingKey, boolean value) { + SelenideElement toggle = Selenide.$("button[name=\"settings[" + settingKey + "]\"]"); + if (value) { + toggle.shouldHave(Condition.cssClass("boolean-toggle-on")); + } else { + toggle.shouldNotHave(Condition.cssClass("boolean-toggle-on")); + } + return this; + } + + public SettingsPage setStringValue(String settingKey, String value) { + SelenideElement setting = Selenide.$(".settings-definition[data-key=\"" + settingKey + "\"]"); + setting.find("input").val(value); + setting.find(".js-save-changes").click(); + setting.find(".js-save-changes").shouldNot(Condition.exist); + return this; + } + + public PropertySetInput getPropertySetInput(String settingKey) { + SelenideElement setting = Selenide.$(".settings-definition[data-key=\"" + settingKey + "\"]"); + return new PropertySetInput(setting); + } +} diff --git a/tests/pom.xml b/tests/pom.xml index b16dedf4259..4850c7b66e2 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -42,6 +42,12 @@ zip provided + + org.sonarsource.sonarqube + sonar-qa-util + ${project.parent.version} + test + org.sonarsource.sonarqube sonar-process diff --git a/tests/src/test/java/org/sonarqube/pageobjects/BackgroundTaskItem.java b/tests/src/test/java/org/sonarqube/pageobjects/BackgroundTaskItem.java deleted file mode 100644 index aedd45ed305..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/BackgroundTaskItem.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.hasText; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class BackgroundTaskItem { - - private final SelenideElement elt; - - public BackgroundTaskItem(SelenideElement elt) { - this.elt = elt; - } - - public SelenideElement getComponent() { - return elt.$("td:nth-child(2)"); - } - - public BackgroundTaskItem openActions() { - elt.$(".js-task-action > .dropdown-toggle").click(); - elt.$(".js-task-action > .dropdown-menu").shouldBe(visible); - return this; - } - - public BackgroundTaskItem openScannerContext () { - elt.$(".js-task-show-scanner-context").click(); - $(".js-task-scanner-context").shouldBe(visible); - return this; - } - - public BackgroundTaskItem assertScannerContextContains(String text) { - $(".js-task-scanner-context").should(hasText(text)); - return this; - } - - public BackgroundTaskItem openErrorStacktrace () { - elt.$(".js-task-show-stacktrace").click(); - $(".js-task-stacktrace").shouldBe(visible); - return this; - } - - public BackgroundTaskItem assertErrorStacktraceContains(String text) { - $(".js-task-stacktrace").should(hasText(text)); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/BackgroundTasksPage.java b/tests/src/test/java/org/sonarqube/pageobjects/BackgroundTasksPage.java deleted file mode 100644 index 432e1addd8c..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/BackgroundTasksPage.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.ElementsCollection; -import java.util.List; -import java.util.stream.Collectors; -import org.openqa.selenium.By; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class BackgroundTasksPage { - - public BackgroundTasksPage() { - $(By.cssSelector(".background-tasks")).should(exist); - } - - public ElementsCollection getTasks() { - return $$(".background-tasks > tbody > tr"); - } - - public List getTasksAsItems() { - return getTasks() - .stream() - .map(BackgroundTaskItem::new) - .collect(Collectors.toList()); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/EncryptionPage.java b/tests/src/test/java/org/sonarqube/pageobjects/EncryptionPage.java deleted file mode 100644 index f0c68849bfe..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/EncryptionPage.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class EncryptionPage extends Navigation { - - public EncryptionPage() { - $("#encryption-page").should(exist); - } - - public SelenideElement generationForm() { - return $("#generate-secret-key-form"); - } - - public SelenideElement newSecretKey() { - return $("#secret-key"); - } - - public String encryptValue(String value) { - $("#encryption-form-value").val(value); - $("#encryption-form").submit(); - return $("#encrypted-value").shouldBe(visible).val(); - } - - public EncryptionPage generateNewKey() { - $("#encryption-new-key-form").submit(); - $("#generate-secret-key-form").shouldBe(visible); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/LoginPage.java b/tests/src/test/java/org/sonarqube/pageobjects/LoginPage.java deleted file mode 100644 index bb17d0961e3..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/LoginPage.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; -import org.openqa.selenium.By; - -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.page; - -public class LoginPage { - - public LoginPage() { - $("#login_form").should(Condition.exist); - } - - public Navigation submitCredentials(String login) { - return submitCredentials(login, login, Navigation.class); - } - - public Navigation submitCredentials(String login, String password) { - return submitCredentials(login, password, Navigation.class); - } - - public Navigation useOAuth2() { - $(".oauth-providers a").click(); - return page(Navigation.class); - } - - public LoginPage submitWrongCredentials(String login, String password) { - $("#login").val(login); - $("#password").val(password); - $(By.name("commit")).click(); - return page(LoginPage.class); - } - - public SelenideElement getErrorMessage() { - return $(".process-spinner-failed"); - } - - private T submitCredentials(String login, String password, Class expectedResultPage) { - $("#login").val(login); - $("#password").val(password); - $(By.name("commit")).click(); - $("#login").should(Condition.disappear); - return page(expectedResultPage); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/MarketplacePage.java b/tests/src/test/java/org/sonarqube/pageobjects/MarketplacePage.java deleted file mode 100644 index 8e69c92e795..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/MarketplacePage.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; -import org.yaml.snakeyaml.error.Mark; - -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class MarketplacePage { - - public MarketplacePage() { - $("#marketplace-page").should(Condition.exist); - } - - public MarketplacePage hasPendingPlugins(String text) { - $(".js-pending").should(Condition.exist).shouldHave(Condition.text(text)); - return this; - } - - public MarketplacePage hasPluginsCount(int count) { - $$("#marketplace-plugins>ul>li").shouldHaveSize(count); - return this; - } - - public MarketplacePage hasPluginWithText(String name, String text) { - getPlugin(name).shouldHave(Condition.text(text)); - return this; - } - - public MarketplacePage searchPlugin(String search) { - $("#marketplace-search input.search-box-input").should(Condition.exist).sendKeys(search); - return this; - } - - public MarketplacePage uninstallPlugin(String name) { - getPlugin(name).$("button.js-uninstall").click(); - return this; - } - - private SelenideElement getPlugin(String name) { - return $$(".js-plugin-name").findBy(Condition.text(name)).should(Condition.exist).parent().parent().parent(); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java deleted file mode 100644 index 8dbe70f84f4..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.SelenideElement; -import com.codeborne.selenide.WebDriverRunner; -import com.sonar.orchestrator.Orchestrator; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.function.Consumer; -import javax.annotation.Nullable; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.html5.WebStorage; -import org.sonarqube.pageobjects.issues.IssuesPage; -import org.sonarqube.pageobjects.measures.MeasuresPage; -import org.sonarqube.pageobjects.organization.MembersPage; -import org.sonarqube.pageobjects.projects.ProjectsPage; -import org.sonarqube.pageobjects.settings.SettingsPage; -import org.sonarqube.tests.Tester; - -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.clearBrowserLocalStorage; -import static com.codeborne.selenide.Selenide.page; - -public class Navigation { - - public Navigation() { - $("#content").shouldBe(Condition.exist); - } - - /** - * @deprecated use {@link Tester#openBrowser()} - */ - @Deprecated - public static Navigation create(Orchestrator orchestrator) { - WebDriver driver = SelenideConfig.configure(orchestrator); - driver.manage().deleteAllCookies(); - clearStorage(d -> d.getLocalStorage().clear()); - clearStorage(d -> d.getSessionStorage().clear()); - clearStorage(d -> clearBrowserLocalStorage()); - return Selenide.open("/", Navigation.class); - } - - private static void clearStorage(Consumer cleaner) { - try { - cleaner.accept((WebStorage) WebDriverRunner.getWebDriver()); - } catch (Exception e) { - // ignore, it may occur when the first test opens browser. No pages are loaded - // and local/session storages are not available yet. - // Example with Chrome: "Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs." - } - } - - public Navigation openHome() { - return open("/", Navigation.class); - } - - public ProjectsPage openProjects() { - return open("/projects", ProjectsPage.class); - } - - public ProjectsPage openProjects(String organization) { - return open("/organizations/" + organization + "/projects", ProjectsPage.class); - } - - public ProjectsPage openProjectsWithQuery(String query) { - return open("/projects?" + query, ProjectsPage.class); - } - - public IssuesPage openIssues() { - return open("/issues", IssuesPage.class); - } - - public IssuesPage openIssues(String organization) { - return open("/organizations/" + organization + "/issues", IssuesPage.class); - } - - public IssuesPage openComponentIssues(String component) { - return open("/component_issues?id=" + component, IssuesPage.class); - } - - public ProjectDashboardPage openProjectDashboard(String projectKey) { - // TODO encode projectKey - String url = "/dashboard?id=" + projectKey; - return open(url, ProjectDashboardPage.class); - } - - public ProjectLinksPage openProjectLinks(String projectKey) { - // TODO encode projectKey - String url = "/project/links?id=" + projectKey; - return open(url, ProjectLinksPage.class); - } - - public QualityGatePage openQualityGates() { - String url = "/quality_gates"; - return open(url, QualityGatePage.class); - } - - public QualityGatePage openQualityGates(String organization) { - String url = "/organizations/" + organization + "/quality_gates"; - return open(url, QualityGatePage.class); - } - - public ProjectQualityGatePage openProjectQualityGate(String projectKey) { - // TODO encode projectKey - String url = "/project/quality_gate?id=" + projectKey; - return open(url, ProjectQualityGatePage.class); - } - - public ProjectKeyPage openProjectKey(String projectKey) { - // TODO encode projectKey - String url = "/project/key?id=" + projectKey; - return open(url, ProjectKeyPage.class); - } - - public ProjectActivityPage openProjectActivity(String projectKey) { - // TODO encode projectKey - String url = "/project/activity?id=" + projectKey; - return open(url, ProjectActivityPage.class); - } - - public MeasuresPage openProjectMeasures(String projectKey) { - // TODO encode projectKey - String url = "/component_measures?id=" + projectKey; - return open(url, MeasuresPage.class); - } - - public ProjectCodePage openCode(String projectKey) { - // TODO encode projectKey - String url = "/code?id=" + projectKey; - return open(url, ProjectCodePage.class); - } - - public ProjectCodePage openCode(String projectKey, String selected) { - // TODO encode projectKey and selected - String url = "/code?id=" + projectKey + "&selected=" + selected; - return open(url, ProjectCodePage.class); - } - - public MembersPage openOrganizationMembers(String orgKey) { - String url = "/organizations/" + orgKey + "/members"; - return open(url, MembersPage.class); - } - - public QualityProfilePage openQualityProfile(String language, String name, String organization) { - String profileUrl = "/quality_profiles/show?language=" + language + "&name=" + name; - return open("/organizations/" + organization + profileUrl , QualityProfilePage.class); - } - - public BackgroundTasksPage openBackgroundTasksPage() { - return open("/background_tasks", BackgroundTasksPage.class); - } - - public SettingsPage openSettings(@Nullable String projectKey) throws UnsupportedEncodingException { - String url = projectKey != null ? "/project/settings?id=" + URLEncoder.encode(projectKey, "UTF-8") : "/settings"; - return open(url, SettingsPage.class); - } - - public EncryptionPage openEncryption() { - return open("/settings/encryption", EncryptionPage.class); - } - - public SystemInfoPage openSystemInfo() { - return open("/admin/system", SystemInfoPage.class); - } - - public MarketplacePage openMarketplace() { return open("/admin/marketplace", MarketplacePage.class);} - - public NotificationsPage openNotifications() { - return open("/account/notifications", NotificationsPage.class); - } - - public ProjectPermissionsPage openProjectPermissions(String projectKey) { - String url = "/project_roles?id=" + projectKey; - return open(url, ProjectPermissionsPage.class); - } - - public ProjectsManagementPage openProjectsManagement() { - return open("/projects_admin", ProjectsManagementPage.class); - } - - public LoginPage openLogin() { - return open("/sessions/login", LoginPage.class); - } - - public void open(String relativeUrl) { - Selenide.open(relativeUrl); - } - - public

    P open(String relativeUrl, Class

    pageObjectClassClass) { - return Selenide.open(relativeUrl, pageObjectClassClass); - } - - public Navigation shouldBeLoggedIn() { - loggedInDropdown().should(visible); - return this; - } - - public Navigation shouldNotBeLoggedIn() { - logInLink().should(visible); - return this; - } - - public LoginPage logIn() { - logInLink().click(); - return page(LoginPage.class); - } - - public Navigation logOut() { - SelenideElement dropdown = loggedInDropdown(); - // click must be on the but not on the dropdown

  • - // for compatibility with phantomjs - dropdown.find(".dropdown-toggle").click(); - dropdown.find(By.linkText("Log out")).click(); - return this; - } - - public RulesPage openRules() { - return open("/coding_rules", RulesPage.class); - } - - public SelenideElement clickOnQualityProfiles() { - return $(By.linkText("Quality Profiles")); - } - - public SelenideElement getRightBar() { - return $("#global-navigation .navbar-right"); - } - - public SelenideElement getFooter() { - return $("#footer"); - } - - public SelenideElement getErrorMessage() { - return $("#error"); - } - - private SelenideElement logInLink() { - return $(By.linkText("Log in")); - } - - private SelenideElement loggedInDropdown() { - return $(".js-user-authenticated"); - } - - public Navigation shouldBeRedirectedToLogin() { - $("#login_form").should(visible); - return this; - } - -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/NotificationsPage.java b/tests/src/test/java/org/sonarqube/pageobjects/NotificationsPage.java deleted file mode 100644 index 456f08ca957..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/NotificationsPage.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import static com.codeborne.selenide.Condition.cssClass; -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class NotificationsPage extends Navigation { - - private final String EMAIL = "EmailNotificationChannel"; - - public NotificationsPage() { - $("#account-page").shouldHave(text("Overall notifications")); - } - - public NotificationsPage shouldHaveGlobalNotification(String type) { - return shouldHaveGlobalNotification(type, EMAIL); - } - - public NotificationsPage shouldHaveGlobalNotification(String type, String channel) { - return shouldBeChecked(globalCheckboxSelector(type, channel)); - } - - public NotificationsPage shouldNotHaveGlobalNotification(String type) { - return shouldNotHaveGlobalNotification(type, EMAIL); - } - - public NotificationsPage shouldNotHaveGlobalNotification(String type, String channel) { - return shouldNotBeChecked(globalCheckboxSelector(type, channel)); - } - - public NotificationsPage shouldHaveProjectNotification(String project, String type, String channel) { - return shouldBeChecked(projectCheckboxSelector(project, type, channel)); - } - - public NotificationsPage shouldNotHaveProjectNotification(String project, String type, String channel) { - return shouldNotBeChecked(projectCheckboxSelector(project, type, channel)); - } - - public NotificationsPage addGlobalNotification(String type) { - return addGlobalNotification(type, EMAIL); - } - - public NotificationsPage addGlobalNotification(String type, String channel) { - shouldNotHaveGlobalNotification(type, channel); - toggleCheckbox(globalCheckboxSelector(type, channel)); - shouldHaveGlobalNotification(type, channel); - return this; - } - - public NotificationsPage removeGlobalNotification(String type) { - return removeGlobalNotification(type, EMAIL); - } - - public NotificationsPage removeGlobalNotification(String type, String channel) { - shouldHaveGlobalNotification(type, channel); - toggleCheckbox(globalCheckboxSelector(type, channel)); - shouldNotHaveGlobalNotification(type, channel); - return this; - } - - public NotificationsPage addProjectNotification(String project, String type, String channel) { - shouldNotHaveProjectNotification(project, type, channel); - toggleCheckbox(projectCheckboxSelector(project, type, channel)); - shouldHaveProjectNotification(project, type, channel); - return this; - } - - public NotificationsPage removeProjectNotification(String project, String type, String channel) { - shouldHaveProjectNotification(project, type, channel); - toggleCheckbox(projectCheckboxSelector(project, type, channel)); - shouldNotHaveProjectNotification(project, type, channel); - return this; - } - - private String globalCheckboxSelector(String type, String channel) { - return "#global-notification-" + type + "-" + channel; - } - - private String projectCheckboxSelector(String project, String type, String channel) { - return "#project-notification-" + project + "-" + type + "-" + channel; - } - - private NotificationsPage shouldBeChecked(String selector) { - $(selector) - .shouldBe(visible) - .shouldHave(cssClass("icon-checkbox-checked")); - return this; - } - - private NotificationsPage shouldNotBeChecked(String selector) { - $(selector) - .shouldBe(visible) - .shouldNotHave(cssClass("icon-checkbox-checked")); - return this; - } - - private void toggleCheckbox(String selector) { - $(selector).click(); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectActivityPage.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectActivityPage.java deleted file mode 100644 index 05479cb6275..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectActivityPage.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import java.util.List; -import java.util.stream.Collectors; - -import static com.codeborne.selenide.Condition.hasText; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class ProjectActivityPage { - - public ProjectActivityPage() { - $("#project-activity").should(Condition.exist); - } - - public ElementsCollection getAnalyses() { - return $$(".project-activity-analysis"); - } - - public List getAnalysesAsItems() { - return getAnalyses() - .stream() - .map(ProjectAnalysisItem::new) - .collect(Collectors.toList()); - } - - public ProjectAnalysisItem getLastAnalysis() { - return new ProjectAnalysisItem($(".project-activity-analysis")); - } - - public ProjectAnalysisItem getFirstAnalysis() { - return new ProjectAnalysisItem($$(".project-activity-analysis").last()); - } - - public ProjectActivityPage assertFirstAnalysisOfTheDayHasText(String day, String text) { - $("#project-activity") - .find(".project-activity-day[data-day=\"" + day + "\"]") - .find(".project-activity-analysis") - .should(hasText(text)); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectAnalysisItem.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectAnalysisItem.java deleted file mode 100644 index dfd1520b812..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectAnalysisItem.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class ProjectAnalysisItem { - - private final SelenideElement elt; - - public ProjectAnalysisItem(SelenideElement elt) { - this.elt = elt; - } - - public ProjectAnalysisItem shouldHaveEventWithText(String text) { - elt.find(".project-activity-events").shouldHave(text(text)); - return this; - } - - public ProjectAnalysisItem shouldHaveDeleteButton() { - elt.find(".js-analysis-actions").click(); - elt.find(".js-delete-analysis").shouldBe(visible); - return this; - } - - public ProjectAnalysisItem shouldNotHaveDeleteButton() { - elt.find(".js-analysis-actions").click(); - elt.find(".js-delete-analysis").shouldNotBe(visible); - return this; - } - - public void delete() { - elt.find(".js-analysis-actions").click(); - elt.find(".js-delete-analysis").click(); - - SelenideElement modal = $(".modal"); - modal.shouldBe(visible); - modal.find("button[type=\"submit\"]").click(); - - elt.shouldNotBe(visible); - } - - public ProjectAnalysisItem addCustomEvent(String name) { - elt.find(".js-analysis-actions").click(); - elt.find(".js-add-event").click(); - - SelenideElement modal = $(".modal"); - modal.shouldBe(visible); - modal.find("input").setValue(name); - modal.find("button[type=\"submit\"]").click(); - - elt.find(".project-activity-event:first-child").shouldHave(text(name)); - return this; - } - - public ProjectAnalysisItem changeFirstEvent(String newName) { - SelenideElement firstEvent = elt.find(".project-activity-event:first-child"); - firstEvent.find(".js-change-event").click(); - - SelenideElement modal = $(".modal"); - modal.shouldBe(visible); - modal.find("input").setValue(newName); - modal.find("button[type=\"submit\"]").click(); - - firstEvent.shouldHave(text(newName)); - return this; - } - - public ProjectAnalysisItem deleteFirstEvent() { - int eventsCount = elt.findAll(".project-activity-event").size(); - - SelenideElement firstEvent = elt.find(".project-activity-event:first-child"); - firstEvent.find(".js-delete-event").click(); - - SelenideElement modal = $(".modal"); - modal.shouldBe(visible); - modal.find("button[type=\"submit\"]").click(); - - elt.findAll(".project-activity-event").shouldHaveSize(eventsCount - 1); - - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectCodePage.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectCodePage.java deleted file mode 100644 index 466ba60f6db..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectCodePage.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class ProjectCodePage { - - public ProjectCodePage() {} - - public ProjectCodePage openFirstComponent() { - $$(".code-name-cell a").first().click(); - return this; - } - - public ProjectCodePage search(String query) { - $(".code-search .search-box-input").val(query); - return this; - } - - public ProjectCodePage shouldHaveComponent(String name) { - $(".code-components").shouldHave(text(name)); - return this; - } - - public ProjectCodePage shouldHaveCode(String code) { - $(".code-components .source-viewer").shouldHave(text(code)); - return this; - } - - public ProjectCodePage shouldHaveBreadcrumbs(String... breadcrumbs) { - for (String breadcrumb : breadcrumbs) { - $(".code-breadcrumbs").shouldHave(text(breadcrumb)); - } - return this; - } - - public ProjectCodePage shouldSearchResult(String name) { - $(".code-search-with-results").shouldHave(text(name)); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectDashboardPage.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectDashboardPage.java deleted file mode 100644 index f1d150e2c16..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectDashboardPage.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; -import java.util.Arrays; -import org.openqa.selenium.By; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.hasText; -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; -import static org.assertj.core.api.Assertions.assertThat; - -public class ProjectDashboardPage { - - public ProjectDashboardPage() { - $(".overview").shouldBe(visible); - } - - public SelenideElement getLinesOfCode() { - SelenideElement element = $("#overview-ncloc"); - element.shouldBe(visible); - return element; - } - - public SelenideElement getLanguageDistribution() { - SelenideElement element = $("#overview-language-distribution"); - element.shouldBe(visible); - return element; - } - - public SelenideElement getOverviewMeasure(String measure) { - ElementsCollection measures = $$(".overview-domain-measure"); - SelenideElement element = measures.find(text(measure)).shouldBe(visible); - return element; - } - - private SelenideElement getTagsMeta() { - SelenideElement element = $(".overview-meta-tags"); - element.shouldBe(visible); - return element; - } - - public ProjectDashboardPage shouldHaveTags(String... tags) { - String tagsList = String.join(", ", Arrays.asList(tags)); - this.getTagsMeta().$(".tags-list > span").should(hasText(tagsList)); - return this; - } - - public ProjectDashboardPage shouldNotBeEditable() { - SelenideElement tagsElem = this.getTagsMeta(); - tagsElem.$("button").shouldNot(exist); - tagsElem.$("div.multi-select").shouldNot(exist); - return this; - } - - public ProjectDashboardPage shouldBeEditable() { - SelenideElement tagsElem = this.getTagsMeta(); - tagsElem.$("button").shouldBe(visible); - return this; - } - - public ProjectDashboardPage openTagEditor() { - SelenideElement tagsElem = this.getTagsMeta(); - tagsElem.$("button").shouldBe(visible).click(); - tagsElem.$("div.multi-select").shouldBe(visible); - return this; - } - - public SelenideElement getTagAtIdx(Integer idx) { - SelenideElement tagsElem = this.getTagsMeta(); - tagsElem.$("div.multi-select").shouldBe(visible); - return tagsElem.$$("ul.menu a").get(idx); - } - - public ProjectDashboardPage sendKeysToTagsInput(CharSequence... charSequences) { - SelenideElement tagsInput = this.getTagsMeta().find("input"); - tagsInput.sendKeys(charSequences); - return this; - } - - public ProjectDashboardPage hasQualityGateLink(String name, String link) { - SelenideElement elem = $$(".overview-meta-card") - .findBy(text("Quality Gate")).should(exist) - .find(By.linkText(name)).should(exist); - assertThat(elem.attr("href")).endsWith(link); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectKeyPage.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectKeyPage.java deleted file mode 100644 index cf72bdadbe5..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectKeyPage.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.hasText; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class ProjectKeyPage { - - public ProjectKeyPage() { - $("#project-key").should(exist); - } - - public ProjectKeyPage assertSimpleUpdate() { - $("#update-key-new-key").shouldBe(visible); - $("#update-key-submit").shouldBe(visible); - return this; - } - - public ProjectKeyPage trySimpleUpdate(String newKey) { - $("#update-key-new-key").val(newKey); - $("#update-key-submit").click(); - $("#update-key-confirm").click(); - return this; - } - - public ProjectKeyPage openFineGrainedUpdate() { - $("#update-key-tab-fine").click(); - $("#project-key-fine-grained-update").shouldBe(visible); - return this; - } - - public ProjectKeyPage tryFineGrainedUpdate(String key, String newKey) { - SelenideElement form = $(".js-fine-grained-update[data-key=\"" + key + "\"]"); - form.shouldBe(visible); - - form.$("input").val(newKey); - form.$("button").click(); - - $("#update-key-confirm").click(); - return this; - } - - public ProjectKeyPage assertBulkChange() { - $("#bulk-update-replace").shouldBe(visible); - $("#bulk-update-by").shouldBe(visible); - $("#bulk-update-see-results").shouldBe(visible); - return this; - } - - public ProjectKeyPage simulateBulkChange(String replace, String by) { - $("#bulk-update-replace").val(replace); - $("#bulk-update-by").val(by); - $("#bulk-update-see-results").click(); - - $("#bulk-update-simulation").shouldBe(visible); - return this; - } - - public ProjectKeyPage assertBulkChangeSimulationResult(String oldKey, String newKey) { - SelenideElement row = $("#bulk-update-results").$("[data-key=\"" + oldKey + "\"]"); - row.$(".js-old-key").should(hasText(oldKey)); - row.$(".js-new-key").should(hasText(newKey)); - return this; - } - - public ProjectKeyPage assertDuplicated(String oldKey) { - SelenideElement row = $("#bulk-update-results").$("[data-key=\"" + oldKey + "\"]"); - row.$(".js-new-key").$(".badge-danger").shouldBe(visible); - return this; - } - - public ProjectKeyPage confirmBulkUpdate() { - $("#bulk-update-confirm").click(); - return this; - } - - public ProjectKeyPage assertSuccessfulBulkUpdate() { - $("#project-key-bulk-update").$(".alert.alert-success").shouldBe(visible); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectLinkItem.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectLinkItem.java deleted file mode 100644 index c652e018e0d..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectLinkItem.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.SelenideElement; -import org.openqa.selenium.NoSuchElementException; - -public class ProjectLinkItem { - - private final SelenideElement elt; - - public ProjectLinkItem(SelenideElement elt) { - this.elt = elt; - } - - public SelenideElement getName() { - return elt.$(".js-name"); - } - - public SelenideElement getType() { - try { - return elt.$(".js-type"); - } catch (NoSuchElementException e) { - return null; - } - } - - public SelenideElement getUrl() { - return elt.$(".js-url"); - } - - public SelenideElement getDeleteButton() { - return elt.$(".js-delete-button"); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectLinksPage.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectLinksPage.java deleted file mode 100644 index a4adbf396f3..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectLinksPage.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; - -import java.util.List; -import java.util.stream.Collectors; - -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class ProjectLinksPage { - - public ProjectLinksPage() { - $("#project-links").should(Condition.exist); - } - - public ElementsCollection getLinks() { - return $$("#project-links tr[data-name]"); - } - - public List getLinksAsItems() { - return getLinks() - .stream() - .map(ProjectLinkItem::new) - .collect(Collectors.toList()); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectPermissionsPage.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectPermissionsPage.java deleted file mode 100644 index 954ad779a07..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectPermissionsPage.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import static com.codeborne.selenide.Condition.cssClass; -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class ProjectPermissionsPage { - - public ProjectPermissionsPage() { - $("#project-permissions-page").should(exist); - } - - public ProjectPermissionsPage shouldBePublic() { - $("#visibility-public .icon-radio.is-checked").shouldBe(visible); - return this; - } - - public ProjectPermissionsPage shouldBePrivate() { - $("#visibility-private .icon-radio.is-checked").shouldBe(visible); - return this; - } - - public ProjectPermissionsPage turnToPublic() { - $("#visibility-public").click(); - $("#confirm-turn-to-public").click(); - shouldBePublic(); - return this; - } - - public ProjectPermissionsPage turnToPrivate() { - $("#visibility-private").click(); - shouldBePrivate(); - return this; - } - - public ProjectPermissionsPage shouldNotAllowPrivate() { - $("#visibility-private").shouldHave(cssClass("text-muted")); - $(".upgrade-organization-box").shouldBe(visible); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectQualityGatePage.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectQualityGatePage.java deleted file mode 100644 index 58e28acaacf..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectQualityGatePage.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Selenide.$; - -public class ProjectQualityGatePage { - - public ProjectQualityGatePage() { - $("#project-quality-gate").should(exist); - } - - public SelenideElement getSelectedQualityGate() { - return $(".Select-value-label"); - } - - public void assertNotSelected() { - $(".Select-placeholder").should(exist); - $(".Select-value-label").shouldNot(exist); - } - - public void setQualityGate(String name) { - $(".Select-input input").val(name).pressEnter(); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectsManagementPage.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectsManagementPage.java deleted file mode 100644 index c2031a8596b..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectsManagementPage.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class ProjectsManagementPage { - - public ProjectsManagementPage() { - $("#projects-management-page").should(exist); - } - - public ProjectsManagementPage shouldHaveProjectsCount(int count) { - $$("#projects-management-page-projects tbody tr").shouldHaveSize(count); - return this; - } - - public ProjectsManagementPage shouldHaveProject(String key) { - $("#projects-management-page-projects").shouldHave(text(key)); - return this; - } - - public ProjectsManagementPage createProject(String key, String name, String visibility) { - $("#create-project").click(); - $("#create-project-name").val(key); - $("#create-project-key").val(name); - $("#visibility-" + visibility).click(); - $("#create-project-submit").submit(); - return this; - } - - public ProjectsManagementPage bulkApplyPermissionTemplate(String template) { - $(".js-bulk-apply-permission-template").click(); - $(".modal .Select-value").click(); - $$(".modal .Select-option").findBy(text(template)).click(); - $(".modal-foot button").click(); - $(".modal-body .alert-success").shouldBe(visible); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/QualityGatePage.java b/tests/src/test/java/org/sonarqube/pageobjects/QualityGatePage.java deleted file mode 100644 index 4133bbfeb92..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/QualityGatePage.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.Condition; - -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class QualityGatePage { - public QualityGatePage() { - $("#quality-gates-page").shouldBe(Condition.visible); - } - - public QualityGatePage countQualityGates(Integer count) { - $$("#quality-gates-page .list-group-item").shouldHaveSize(count); - return this; - } - - public QualityGatePage canCreateQG() { - $("#quality-gate-add").should(Condition.exist).shouldBe(Condition.visible); - return this; - } - - public QualityGatePage canNotCreateQG() { - $("#quality-gate-add").shouldNot(Condition.exist); - return this; - } - - public QualityGatePage displayIntro() { - $(".search-navigator-intro").should(Condition.exist).shouldBe(Condition.visible); - return this; - } - - public QualityGatePage displayQualityGateDetail(String qualityGateName) { - $(".layout-page-main-header").shouldHave(Condition.text(qualityGateName)); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/QualityProfilePage.java b/tests/src/test/java/org/sonarqube/pageobjects/QualityProfilePage.java deleted file mode 100644 index 803f55357a0..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/QualityProfilePage.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.Condition; - -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.page; - -public class QualityProfilePage { - public QualityProfilePage() { - $("#quality-profile").shouldBe(Condition.visible); - } - - public QualityProfilePage shouldHaveMissingSonarWayRules(Integer nbRules) { - $(".quality-profile-rules-sonarway-missing") - .shouldBe(Condition.visible) - .$("a").shouldHave(text(nbRules.toString())); - return this; - } - - public RulesPage showMissingSonarWayRules() { - $(".quality-profile-rules-sonarway-missing") - .shouldBe(Condition.visible).$("a").click(); - $(".coding-rules").shouldBe(Condition.visible); - return page(RulesPage.class); - } - - public QualityProfilePage shouldHaveAssociatedProject(String projectName) { - $(".js-profile-project").shouldHave(text(projectName)); - return this; - } - - public QualityProfilePage shouldAllowToChangeProjects() { - $(".js-change-projects").shouldBe(visible).click(); - $("#profile-projects .select-list-list").shouldBe(visible); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/RuleDetails.java b/tests/src/test/java/org/sonarqube/pageobjects/RuleDetails.java deleted file mode 100644 index fda58ded977..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/RuleDetails.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Selenide.$; - -public class RuleDetails { - - private final SelenideElement elt; - - public RuleDetails(SelenideElement elt) { - this.elt = elt; - } - - public RuleDetails shouldBeActivatedOn(String profileName) { - $("#coding-rules-detail-quality-profiles").shouldHave(text(profileName)); - return this; - } - -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/RuleItem.java b/tests/src/test/java/org/sonarqube/pageobjects/RuleItem.java deleted file mode 100644 index b311f3555b8..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/RuleItem.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.SelenideElement; - -public class RuleItem { - - private final SelenideElement elt; - - public RuleItem(SelenideElement elt) { - this.elt = elt; - } - - public SelenideElement getTitle() { - return elt.$(".coding-rule-title"); - } - - public SelenideElement getMetadata() { - return elt.$(".coding-rule-meta"); - } - - -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java b/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java deleted file mode 100644 index e3f5afbac66..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; -import org.openqa.selenium.By; - -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class RulesPage extends Navigation { - - public RulesPage() { - $(By.cssSelector(".coding-rules")).should(Condition.exist); - } - - public int getTotal() { - // warning - number is localized - return Integer.parseInt($("#coding-rules-total").text()); - } - - public ElementsCollection getSelectedFacetItems(String facetName) { - SelenideElement facet = $(".search-navigator-facet-box[data-property='"+ facetName+"']").shouldBe(Condition.visible); - return facet.$$(".js-facet.active"); - } - - public RulesPage shouldHaveTotalRules(Integer total) { - $("#coding-rules-total").shouldHave(text(total.toString())); - return this; - } - - public RulesPage openFacet(String facet) { - $(".search-navigator-facet-box[data-property=\"" + facet + "\"] .js-facet-toggle").click(); - return this; - } - - public RulesPage selectFacetItemByText(String facet, String itemText) { - $$(".search-navigator-facet-box[data-property=\"" + facet + "\"] .js-facet") - .findBy(text(itemText)).click(); - return this; - } - - public RuleDetails openFirstRule() { - $$(".js-rule").first().click(); - $(".coding-rules-details").shouldBe(visible); - return new RuleDetails($(".coding-rules-details")); - } - -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/SelenideConfig.java b/tests/src/test/java/org/sonarqube/pageobjects/SelenideConfig.java deleted file mode 100644 index 32c6850f917..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/SelenideConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.Configuration; -import com.codeborne.selenide.WebDriverRunner; -import com.sonar.orchestrator.Orchestrator; -import java.util.stream.Collectors; -import org.openqa.selenium.WebDriver; - -import static java.util.Arrays.stream; - -public class SelenideConfig { - - private enum Browser { - firefox("(v46 and lower)"), - marionette("(recent Firefox, require Geckodriver)"), - chrome("(require Chromedriver)"); - - private final String label; - - Browser(String label) { - this.label = label; - } - - static Browser of(String s) { - try { - return Browser.valueOf(s); - } catch (Exception e) { - throw new IllegalArgumentException("Invalid browser: " + s + ". Supported values are " + - stream(values()).map(b -> b.name() + " " + b.label).collect(Collectors.joining(", "))); - } - } - } - - public static WebDriver configure(Orchestrator orchestrator) { - String browserKey = orchestrator.getConfiguration().getString("orchestrator.browser", Browser.firefox.name()); - Browser browser = Browser.of(browserKey); - Configuration.browser = browser.name(); - Configuration.baseUrl = orchestrator.getServer().getUrl(); - Configuration.timeout = 8_000; - Configuration.reportsFolder = "target/screenshots"; - Configuration.screenshots = true; - Configuration.captureJavascriptErrors = true; - Configuration.savePageSource = true; - Configuration.browserSize = "1280x1024"; - return getWebDriver(); - } - - static WebDriver getWebDriver() { - return WebDriverRunner.getWebDriver(); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPage.java b/tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPage.java deleted file mode 100644 index 64d3576873f..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPage.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class SystemInfoPage { - public SystemInfoPage() { - $(".page-title").should(exist).shouldHave(text("System Info")); - } - - public SystemInfoPage shouldHaveCard(String title) { - $$(".system-info-health-card-title").find(text(title)).should(exist); - return this; - } - - public SystemInfoPage shouldHaveCards(String... titles) { - $$(".system-info-health-card-title").shouldHave(CollectionCondition.texts(titles)); - return this; - } - - public SystemInfoPageItem getCardItem(String card) { - SelenideElement cardTitle = $$(".system-info-health-card-title").find(text(card)).should(exist); - return new SystemInfoPageItem(cardTitle.parent().parent()); - } -} \ No newline at end of file diff --git a/tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPageItem.java b/tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPageItem.java deleted file mode 100644 index c477c874cb3..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPageItem.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.exactText; -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.text; - -public class SystemInfoPageItem { - private final SelenideElement elt; - - public SystemInfoPageItem(SelenideElement elt) { - this.elt = elt; - } - - public SystemInfoPageItem shouldHaveHealth() { - elt.$(".system-info-health-info .status-indicator").should(exist); - return this; - } - - public SystemInfoPageItem shouldHaveSection(String section) { - ensureOpen(); - elt.$$("h4").findBy(text(section)).should(exist); - return this; - } - - public SystemInfoPageItem shouldNotHaveSection(String section) { - ensureOpen(); - elt.$$("h4").findBy(text(section)).shouldNot(exist); - return this; - } - - public SystemInfoPageItem shouldHaveMainSection() { - ensureOpen(); - elt.$$(".system-info-section").get(0).find("h4").shouldNot(exist); - return this; - } - - public SystemInfoPageItem shouldHaveField(String field) { - ensureOpen(); - elt.$$(".system-info-section-item-name").findBy(text(field)).should(exist); - return this; - } - - public SystemInfoPageItem shouldNotHaveField(String field) { - ensureOpen(); - elt.$$(".system-info-section-item-name").findBy(exactText(field)).shouldNot(exist); - return this; - } - - public SystemInfoPageItem shouldHaveFieldWithValue(String field, String value) { - ensureOpen(); - SelenideElement fieldElem = elt.$$(".system-info-section-item-name").findBy(text(field)).should(exist); - fieldElem.parent().parent().$$("td").shouldHaveSize(2).get(1).shouldHave(text(value)); - return this; - } - - public SystemInfoPageItem ensureOpen() { - if(!isOpen()) { - elt.click(); - elt.$(".boxed-group-inner").should(exist); - } - return this; - } - - private boolean isOpen() { - return elt.$(".boxed-group-inner").exists(); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/issues/Issue.java b/tests/src/test/java/org/sonarqube/pageobjects/issues/Issue.java deleted file mode 100644 index a2c6e64648e..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/issues/Issue.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects.issues; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class Issue { - - private final SelenideElement elt; - - public Issue(SelenideElement elt) { - this.elt = elt; - } - - public Issue shouldAllowAssign() { - elt.find(".js-issue-assign").shouldBe(visible); - return this; - } - - public Issue shouldAllowChangeType() { - elt.find(".js-issue-set-type").shouldBe(visible); - return this; - } - - public Issue shouldNotAllowAssign() { - elt.find(".js-issue-assign").shouldNotBe(visible); - return this; - } - - public Issue shouldNotAllowChangeType() { - elt.find(".js-issue-set-type").shouldNotBe(visible); - return this; - } - - public Issue assigneeSearchResultCount(String query, Integer count) { - SelenideElement assignLink = elt.find(".js-issue-assign"); - assignLink.click(); - SelenideElement popupMenu = $(".bubble-popup ul.menu").shouldBe(visible); - $(".bubble-popup input.search-box-input").shouldBe(visible).val("").sendKeys(query); - popupMenu.$("li a[data-text='Not assigned']").shouldNot(exist); - popupMenu.$$("li").shouldHaveSize(count); - assignLink.click(); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/issues/IssuesPage.java b/tests/src/test/java/org/sonarqube/pageobjects/issues/IssuesPage.java deleted file mode 100644 index 0918af6b0ae..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/issues/IssuesPage.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects.issues; - -import com.codeborne.selenide.ElementsCollection; -import java.util.List; -import java.util.stream.Collectors; - -import static com.codeborne.selenide.CollectionCondition.sizeGreaterThan; -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class IssuesPage { - - public IssuesPage() { - $(".issues").should(exist); - } - - private ElementsCollection getIssuesElements() { - return $$(".issues .issue"); - } - - private ElementsCollection getIssuesPathComponents() { - return $$(".issues-workspace-list-component"); - } - - public List getIssues() { - return getIssuesElements() - .stream() - .map(Issue::new) - .collect(Collectors.toList()); - } - - public IssuesPage issuesCount(Integer count) { - this.getIssuesElements().shouldHaveSize(count); - return this; - } - - public Issue getFirstIssue() { - getIssuesElements().shouldHave(sizeGreaterThan(0)); - return new Issue(getIssuesElements().first()); - } - - public IssuesPage componentsShouldContain(String path) { - this.getIssuesPathComponents().forEach(element -> element.shouldHave(text(path))); - return this; - } - - public IssuesPage componentsShouldNotContain(String path) { - this.getIssuesPathComponents().forEach(element -> element.shouldNotHave(text(path))); - return this; - } - - public IssuesPage bulkChangeOpen() { - $("#issues-bulk-change").shouldBe(visible).click(); - $("#bulk-change-form").shouldBe(visible); - return this; - } - - public IssuesPage bulkChangeAssigneeSearchCount(String query, Integer count) { - $("#issues-bulk-change-assignee .Select-input input").val(query); - $$("#issues-bulk-change-assignee .Select-option").shouldHaveSize(count); - $("#issues-bulk-change-assignee .Select-input input").pressEscape(); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/measures/MeasureContent.java b/tests/src/test/java/org/sonarqube/pageobjects/measures/MeasureContent.java deleted file mode 100644 index 6c8e7381098..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/measures/MeasureContent.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects.measures; - -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.text; - -public class MeasureContent { - private final SelenideElement elt; - - public MeasureContent(SelenideElement elt) { - this.elt = elt; - } - - public MeasureContent shouldHaveTitle(String title) { - this.elt.$(".measure-details-header .measure-details-metric").should(exist).shouldHave(text(title)); - return this; - } - - public MeasureContent shouldHaveHeaderValue(String value) { - this.elt.$(".measure-details-header .measure-details-value").should(exist).shouldHave(text(value)); - return this; - } - - public MeasureContent shouldHaveFile(String path) { - this.getFiles().find(text(path)).should(exist); - return this; - } - - public MeasureContent drillDown(String item) { - this.getFiles().find(text(item)).should(exist).find("a").click(); - return this; - } - - public MeasureContent shouldDisplayCode() { - this.elt.$(".source-line-code").should(exist); - return this; - } - - private ElementsCollection getFiles() { - return this.elt.$$(".measure-details-component-row"); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/measures/MeasuresPage.java b/tests/src/test/java/org/sonarqube/pageobjects/measures/MeasuresPage.java deleted file mode 100644 index 414b7f8c61b..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/measures/MeasuresPage.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects.measures; -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.SelenideElement; -import org.openqa.selenium.Keys; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class MeasuresPage { - public MeasuresPage() { - $("#component-measures").should(exist); - } - - public MeasuresPage displayBubbleChart(String title) { - SelenideElement bubblechart = $("#component-measures .measure-overview-bubble-chart"); - bubblechart.$(".measure-overview-bubble-chart-title").shouldHave(text(title)); - return this; - } - - public MeasuresPage measureHasValue(String measure, Integer value) { - SelenideElement sidebar = this.getSideBar(); - sidebar.$("#measure-" + measure + "-name").should(exist); - sidebar.$("#measure-" + measure + "-value").should(exist).shouldHave(text(value.toString())); - return this; - } - - public MeasuresPage measureHasLeak(String measure, Integer value) { - SelenideElement sidebar = this.getSideBar(); - sidebar.$("#measure-" + measure + "-name").should(exist); - sidebar.$("#measure-" + measure + "-leak").should(exist).shouldHave(text(value.toString())); - return this; - } - - public MeasuresPage breadcrumbsShouldHave(String item) { - $(".layout-page-header-panel .measure-breadcrumbs").shouldHave(text(item)); - return this; - } - - public MeasuresPage breadcrumbsShouldNotHave(String item) { - $(".layout-page-header-panel .measure-breadcrumbs").shouldNotHave(text(item)); - return this; - } - - public MeasuresPage backShortcut() { - $(".layout-page-header-panel").sendKeys(Keys.LEFT); - return this; - } - - public MeasuresPage switchView(String view) { - SelenideElement select = $(".measure-view-select").should(exist); - select.click(); - select.$(".Select-menu-outer").should(exist) - .$$(".Select-option").shouldHave(CollectionCondition.sizeGreaterThan(1)) - .find(text(view)).should(exist).click(); - return this; - } - - public MeasuresPage openFacet(String facet) { - SelenideElement facetBox = $$(".search-navigator-facet-box").find(text(facet)); - if(!facetBox.find("search-navigator-facet-list").isDisplayed()) { - facetBox.$(".search-navigator-facet-header a").should(exist).click(); - } - return this; - } - - public MeasureContent openMeasureContent(String measure) { - SelenideElement sidebar = this.getSideBar(); - SelenideElement facetItem = sidebar.$("#measure-" + measure + "-name"); - facetItem.click(); - MeasureContent content = new MeasureContent($("#component-measures .measure-details-content").should(exist)); - content.shouldHaveTitle(facetItem.getText()); - return content; - } - - private SelenideElement getSideBar() { - return $("#component-measures .layout-page-side").should(exist); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/organization/MemberItem.java b/tests/src/test/java/org/sonarqube/pageobjects/organization/MemberItem.java deleted file mode 100644 index 0de4be4c937..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/organization/MemberItem.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonarqube.pageobjects.organization; - -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Selenide.$; - -public class MemberItem { - private final SelenideElement elt; - - public MemberItem(SelenideElement elt) { - this.elt = elt; - } - - public MemberItem shouldBeNamed(String login, String name) { - ElementsCollection tds = this.elt.$$("td"); - tds.get(1).$("strong").shouldHave(Condition.text(name)); - tds.get(1).$("span").shouldHave(Condition.text(login)); - return this; - } - - public MemberItem shouldHaveGroups(Integer groups) { - ElementsCollection tds = this.elt.$$("td"); - tds.get(2).should(Condition.exist); - tds.get(2).shouldHave(Condition.text(groups.toString())); - return this; - } - - public MemberItem shouldNotHaveActions() { - this.elt.$$("td").shouldHave(CollectionCondition.sizeLessThan(3)); - return this; - } - - public MemberItem removeMembership() { - ElementsCollection tds = this.elt.$$("td"); - tds.shouldHave(CollectionCondition.sizeGreaterThan(3)); - SelenideElement actionTd = tds.get(3); - actionTd.$("button").should(Condition.exist).click(); - actionTd.$$(".dropdown-menu > li").get(2).shouldBe(Condition.visible).click(); - SelenideElement modal = getModal("Remove user"); - modal.$("button.button-red").shouldBe(Condition.visible).click(); - return this; - } - - public MemberItem manageGroupsOpen() { - ElementsCollection tds = this.elt.$$("td"); - tds.shouldHave(CollectionCondition.sizeGreaterThan(3)); - SelenideElement actionTd = tds.get(3); - actionTd.$("button").should(Condition.exist).click(); - actionTd.$$(".dropdown-menu > li").get(0).shouldBe(Condition.visible).click(); - getModal("Manage groups"); - return this; - } - - public MemberItem manageGroupsSelect(String group) { - SelenideElement modal = getModal("Manage groups"); - modal.$$("li").find(Condition.text(group)).shouldBe(Condition.visible).click(); - return this; - } - - public MemberItem manageGroupsSave() { - SelenideElement modal = getModal("Manage groups"); - modal.$("button[type='submit']").shouldBe(Condition.visible).click(); - return this; - } - - private SelenideElement getModal(String title) { - $(".modal-head").should(Condition.exist).shouldHave(Condition.text(title)); - SelenideElement form = $(".ReactModalPortal form"); - form.should(Condition.exist); - return form; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/organization/MembersPage.java b/tests/src/test/java/org/sonarqube/pageobjects/organization/MembersPage.java deleted file mode 100644 index a6e6081438b..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/organization/MembersPage.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonarqube.pageobjects.organization; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -public class MembersPage { - - public MembersPage() { - $(".navbar-tabs a.active").shouldBe(visible).shouldHave(text("Members")); - } - - public ElementsCollection getMembers() { - return $$("table.data tr"); - } - - public MemberItem getMembersByIdx(Integer idx) { - return new MemberItem(getMembers().get(idx)); - } - - public MembersPage shouldHaveTotal(int total) { - $(".panel-vertical > span > strong").shouldHave(text(String.valueOf(total))); - return this; - } - - public MembersPage searchForMember(String query) { - $(".page .search-box-input").shouldBe(visible).val("").sendKeys(query); - return this; - } - - public MembersPage canAddMember() { - $(".page-actions").shouldBe(visible); - return this; - } - - public MembersPage canNotAddMember() { - $(".page-actions").shouldNot(Condition.exist); - return this; - } - - public MembersPage addMember(String login) { - this.canAddMember(); - $(".page-actions button").click(); - - SelenideElement modal = this.getModal("Add user"); - SelenideElement input = modal.$(".Select-input input"); - input.val(login); - modal.$("div.Select-option.is-focused").should(Condition.exist); - input.pressEnter(); - modal.$("button[type='submit']").click(); - return this; - } - - private SelenideElement getModal(String title) { - $(".modal-head").should(Condition.exist).shouldHave(text(title)); - SelenideElement form = $(".ReactModalPortal form"); - form.should(Condition.exist); - return form; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/projects/FacetItem.java b/tests/src/test/java/org/sonarqube/pageobjects/projects/FacetItem.java deleted file mode 100644 index ec3197c5a62..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/projects/FacetItem.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects.projects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; - -public class FacetItem { - - private final SelenideElement elt; - - public FacetItem(SelenideElement elt) { - this.elt = elt; - } - - public FacetItem shouldHaveValue(String key, String value) { - this.elt.$(".facet[data-key=\"" + key + "\"] .facet-stat").shouldHave(Condition.text(value)); - return this; - } - - public void selectValue(String key) { - this.elt.$(".facet[data-key=\"" + key + "\"]").click(); - } - - public FacetItem selectOptionItem(String value) { - SelenideElement selectInput = this.elt.$(".Select-input input"); - selectInput.val(value); - this.elt.$("div.Select-option.is-focused").should(Condition.exist); - selectInput.pressEnter(); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/projects/ProjectItem.java b/tests/src/test/java/org/sonarqube/pageobjects/projects/ProjectItem.java deleted file mode 100644 index 6261efa9129..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/projects/ProjectItem.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects.projects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; - -public class ProjectItem { - - private final SelenideElement elt; - - public ProjectItem(SelenideElement elt) { - this.elt = elt; - } - - public ProjectItem shouldHaveMeasure(String metricKey, String value) { - this.elt.$(".project-card-measure[data-key=\"" + metricKey + "\"]").shouldHave(Condition.text(value)); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/projects/ProjectsPage.java b/tests/src/test/java/org/sonarqube/pageobjects/projects/ProjectsPage.java deleted file mode 100644 index 767c2fbf2d8..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/projects/ProjectsPage.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects.projects; - -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; -import static com.codeborne.selenide.WebDriverRunner.url; -import static org.assertj.core.api.Assertions.assertThat; - -public class ProjectsPage { - - public ProjectsPage() { - $("#projects-page").shouldBe(visible); - } - - public ElementsCollection getProjects() { - return $$(".projects-list > .boxed-group"); - } - - public ElementsCollection getFacets() { - return $$(".search-navigator-facet-box"); - } - - public ProjectItem getProjectByKey(String projectKey) { - SelenideElement element = getProjects().find(Condition.attribute("data-key", projectKey)); - return new ProjectItem(element); - } - - public ProjectItem getProjectByIdx(Integer idx) { - return new ProjectItem(getProjects().get(idx)); - } - - public FacetItem getFacetByProperty(String facetProperty) { - SelenideElement element = getFacets().find(Condition.attribute("data-key", facetProperty)); - return new FacetItem(element); - } - - public ProjectsPage shouldHaveTotal(int total) { - // warning - number is localized - $("#projects-total").shouldHave(text(String.valueOf(total))); - return this; - } - - public ProjectsPage shouldDisplayAllProjects() { - assertThat(url()).endsWith("/projects"); - return this; - } - - public ProjectsPage shouldDisplayAllProjectsWidthSort(String sort) { - assertThat(url()).endsWith("/projects?sort=" + sort); - return this; - } - - public ProjectsPage shouldDisplayFavoriteProjects() { - assertThat(url()).endsWith("/projects/favorite"); - return this; - } - - public ProjectsPage selectAllProjects() { - $("#all-projects").click(); - return shouldDisplayAllProjects(); - } - - public ProjectsPage selectFavoriteProjects() { - $("#favorite-projects").click(); - return shouldDisplayFavoriteProjects(); - } - - public ProjectsPage searchProject(String search) { - SelenideElement searchInput = $(".projects-topbar-item-search input"); - searchInput.setValue("").sendKeys(search); - return this; - } - - public ProjectsPage changePerspective(String perspective) { - SelenideElement sortSelect = getOpenTopBar().$(".js-projects-perspective-select"); - sortSelect.$(".Select-value").should(Condition.exist).click(); - sortSelect.$(".Select-option[title='" + perspective + "']").should(Condition.exist).click(); - return this; - } - - public ProjectsPage sortProjects(String sort) { - SelenideElement sortSelect = getOpenTopBar().$(".js-projects-sorting-select"); - sortSelect.$(".Select-value").should(Condition.exist).click(); - sortSelect.$(".Select-option[title='" + sort + "']").should(Condition.exist).click(); - return this; - } - - public ProjectsPage invertSorting() { - getOpenTopBar().$(".js-projects-sorting-invert").should(Condition.exist).click(); - return this; - } - - private SelenideElement getOpenTopBar() { - return $(".projects-topbar-items").should(Condition.exist); - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/settings/PropertySetInput.java b/tests/src/test/java/org/sonarqube/pageobjects/settings/PropertySetInput.java deleted file mode 100644 index 4f1c7db3a32..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/settings/PropertySetInput.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects.settings; - -import com.codeborne.selenide.SelenideElement; - -import static com.codeborne.selenide.Condition.exist; - -public class PropertySetInput { - - private final SelenideElement elt; - - public PropertySetInput(SelenideElement elt) { - this.elt = elt; - } - - public PropertySetInput setFieldValue(int index, String fieldKey, String value) { - elt.findAll("input[name$=\"[" + fieldKey + "]\"]").get(index).val(value); - return this; - } - - public PropertySetInput setFieldValue(String fieldKey, String value) { - return setFieldValue(0, fieldKey, value); - } - - public PropertySetInput save() { - elt.find(".js-save-changes").click(); - elt.find(".js-save-changes").shouldNot(exist); - return this; - } -} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/settings/SettingsPage.java b/tests/src/test/java/org/sonarqube/pageobjects/settings/SettingsPage.java deleted file mode 100644 index 1d1af886d1e..00000000000 --- a/tests/src/test/java/org/sonarqube/pageobjects/settings/SettingsPage.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarqube.pageobjects.settings; - -import com.codeborne.selenide.SelenideElement; -import org.openqa.selenium.By; - -import static com.codeborne.selenide.Condition.cssClass; -import static com.codeborne.selenide.Condition.exactValue; -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.visible; -import static com.codeborne.selenide.Selenide.$; - -public class SettingsPage { - - public SettingsPage() { - $("#settings-page").shouldBe(visible); - } - - public SettingsPage assertMenuContains(String categoryName) { - $(".side-tabs-menu").$(By.linkText(categoryName)).shouldBe(visible); - return this; - } - - public SettingsPage assertSettingDisplayed(String settingKey) { - $(".settings-definition[data-key='" + settingKey + "']").shouldBe(visible); - return this; - } - - public SettingsPage assertSettingNotDisplayed(String settingKey) { - $(".settings-definition[data-key='" + settingKey + "']").shouldNotBe(visible); - return this; - } - - public SettingsPage openCategory(String categoryName) { - $(".side-tabs-menu").$(By.linkText(categoryName)).click(); - return this; - } - - public SettingsPage assertStringSettingValue(String settingKey, String value) { - $("input[name=\"settings[" + settingKey + "]\"]").shouldHave(exactValue(value)); - return this; - } - - public SettingsPage assertBooleanSettingValue(String settingKey, boolean value) { - SelenideElement toggle = $("button[name=\"settings[" + settingKey + "]\"]"); - if (value) { - toggle.shouldHave(cssClass("boolean-toggle-on")); - } else { - toggle.shouldNotHave(cssClass("boolean-toggle-on")); - } - return this; - } - - public SettingsPage setStringValue(String settingKey, String value) { - SelenideElement setting = $(".settings-definition[data-key=\"" + settingKey + "\"]"); - setting.find("input").val(value); - setting.find(".js-save-changes").click(); - setting.find(".js-save-changes").shouldNot(exist); - return this; - } - - public PropertySetInput getPropertySetInput(String settingKey) { - SelenideElement setting = $(".settings-definition[data-key=\"" + settingKey + "\"]"); - return new PropertySetInput(setting); - } -} diff --git a/tests/src/test/java/org/sonarqube/tests/Tester.java b/tests/src/test/java/org/sonarqube/tests/Tester.java index 43ea1fe380b..8f5e58ffbbc 100644 --- a/tests/src/test/java/org/sonarqube/tests/Tester.java +++ b/tests/src/test/java/org/sonarqube/tests/Tester.java @@ -23,7 +23,7 @@ import com.sonar.orchestrator.Orchestrator; import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.junit.rules.ExternalResource; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.Navigation; import org.sonarqube.ws.client.WsClient; import util.selenium.Selenese; diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssuesPageTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssuesPageTest.java index cc3829b78e2..e3065647298 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssuesPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssuesPageTest.java @@ -26,9 +26,9 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.issues.Issue; -import org.sonarqube.pageobjects.issues.IssuesPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.issues.Issue; +import org.sonarqube.qa.util.pageobjects.issues.IssuesPage; import util.ItUtils; import util.user.UserRule; diff --git a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java index 683b808fbbe..a9e5bcf3eee 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssueAssignTest.java @@ -38,7 +38,7 @@ import org.sonarqube.ws.client.issue.BulkChangeRequest; import org.sonarqube.ws.client.issue.SearchWsRequest; import org.sonarqube.ws.client.project.CreateRequest; import org.sonarqube.ws.client.qualityprofile.AddProjectRequest; -import org.sonarqube.pageobjects.issues.IssuesPage; +import org.sonarqube.qa.util.pageobjects.issues.IssuesPage; import util.issue.IssueRule; import static java.lang.String.format; diff --git a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssuesPageTest.java b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssuesPageTest.java index 979467ee693..df0e4c58dd9 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssuesPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssuesPageTest.java @@ -25,7 +25,7 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.Navigation; import org.sonarqube.tests.Category6Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.Organizations; diff --git a/tests/src/test/java/org/sonarqube/tests/marketplace/UpdateCenterTest.java b/tests/src/test/java/org/sonarqube/tests/marketplace/UpdateCenterTest.java index 220be947dcd..83dc231470c 100644 --- a/tests/src/test/java/org/sonarqube/tests/marketplace/UpdateCenterTest.java +++ b/tests/src/test/java/org/sonarqube/tests/marketplace/UpdateCenterTest.java @@ -24,8 +24,8 @@ import org.junit.After; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.MarketplacePage; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.MarketplacePage; +import org.sonarqube.qa.util.pageobjects.Navigation; import util.user.UserRule; import static util.ItUtils.pluginArtifact; diff --git a/tests/src/test/java/org/sonarqube/tests/measure/DifferentialPeriodsTest.java b/tests/src/test/java/org/sonarqube/tests/measure/DifferentialPeriodsTest.java index 8df93be6cf6..a9b2b814ea3 100644 --- a/tests/src/test/java/org/sonarqube/tests/measure/DifferentialPeriodsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/measure/DifferentialPeriodsTest.java @@ -29,7 +29,7 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.Navigation; import util.ItUtils; import util.user.UserRule; diff --git a/tests/src/test/java/org/sonarqube/tests/measure/ProjectDashboardTest.java b/tests/src/test/java/org/sonarqube/tests/measure/ProjectDashboardTest.java index 956c8e7f109..02d59fa7222 100644 --- a/tests/src/test/java/org/sonarqube/tests/measure/ProjectDashboardTest.java +++ b/tests/src/test/java/org/sonarqube/tests/measure/ProjectDashboardTest.java @@ -30,14 +30,13 @@ import org.junit.Test; import org.openqa.selenium.Keys; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.ProjectDashboardPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.ProjectDashboardPage; import util.user.UserRule; import static com.codeborne.selenide.Condition.exist; import static com.codeborne.selenide.Condition.hasText; import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Condition.visible; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.projectDir; import static util.selenium.Selenese.runSelenese; diff --git a/tests/src/test/java/org/sonarqube/tests/measure/ProjectMeasuresPageTest.java b/tests/src/test/java/org/sonarqube/tests/measure/ProjectMeasuresPageTest.java index f2466a2b3d7..2ea1009b617 100644 --- a/tests/src/test/java/org/sonarqube/tests/measure/ProjectMeasuresPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/measure/ProjectMeasuresPageTest.java @@ -25,9 +25,9 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.measures.MeasureContent; -import org.sonarqube.pageobjects.measures.MeasuresPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.measures.MeasureContent; +import org.sonarqube.qa.util.pageobjects.measures.MeasuresPage; import org.sonarqube.tests.Category1Suite; import org.sonarqube.tests.Tester; diff --git a/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java b/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java index 22d209954e3..730298db1e6 100644 --- a/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java +++ b/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java @@ -36,7 +36,7 @@ import org.sonarqube.ws.client.WsResponse; import org.sonarqube.ws.client.organization.UpdateProjectVisibilityWsRequest; import org.sonarqube.ws.client.project.CreateRequest; import org.sonarqube.ws.client.project.UpdateVisibilityRequest; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.Navigation; import util.ItUtils; import static java.lang.String.format; diff --git a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipUiTest.java b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipUiTest.java index a3a47279ed7..817248a14fb 100644 --- a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipUiTest.java @@ -26,7 +26,7 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.organization.MembersPage; +import org.sonarqube.qa.util.pageobjects.organization.MembersPage; import org.sonarqube.tests.Category6Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.Organizations.Organization; diff --git a/tests/src/test/java/org/sonarqube/tests/projectAdministration/BackgroundTasksTest.java b/tests/src/test/java/org/sonarqube/tests/projectAdministration/BackgroundTasksTest.java index 0c4e916ebf7..0e7eee2e783 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectAdministration/BackgroundTasksTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectAdministration/BackgroundTasksTest.java @@ -28,9 +28,9 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.BackgroundTaskItem; -import org.sonarqube.pageobjects.BackgroundTasksPage; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.BackgroundTaskItem; +import org.sonarqube.qa.util.pageobjects.BackgroundTasksPage; +import org.sonarqube.qa.util.pageobjects.Navigation; import util.user.UserRule; import static com.codeborne.selenide.CollectionCondition.sizeGreaterThan; diff --git a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectAdministrationTest.java b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectAdministrationTest.java index b2f72b1017c..88f75d55db5 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectAdministrationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectAdministrationTest.java @@ -38,9 +38,9 @@ import org.openqa.selenium.By; import org.sonar.wsclient.SonarClient; import org.sonar.wsclient.base.HttpException; import org.sonar.wsclient.user.UserParameters; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.ProjectsManagementPage; -import org.sonarqube.pageobjects.settings.SettingsPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.ProjectsManagementPage; +import org.sonarqube.qa.util.pageobjects.settings.SettingsPage; import org.sonarqube.tests.Category1Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.WsPermissions; diff --git a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectKeyUpdatePageTest.java b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectKeyUpdatePageTest.java index fb9572d3748..b907898c6ee 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectKeyUpdatePageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectKeyUpdatePageTest.java @@ -28,8 +28,8 @@ import org.junit.ClassRule; import org.junit.Test; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.ProjectKeyPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.ProjectKeyPage; import static com.codeborne.selenide.Condition.visible; import static com.codeborne.selenide.Selenide.$; diff --git a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectLinksPageTest.java b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectLinksPageTest.java index 5cb04c3b4e8..b6ad18a16b5 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectLinksPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectLinksPageTest.java @@ -34,9 +34,9 @@ import org.sonarqube.ws.WsProjectLinks.CreateWsResponse; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.projectlinks.CreateWsRequest; import org.sonarqube.ws.client.projectlinks.DeleteWsRequest; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.ProjectLinkItem; -import org.sonarqube.pageobjects.ProjectLinksPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.ProjectLinkItem; +import org.sonarqube.qa.util.pageobjects.ProjectLinksPage; import util.user.UserRule; import static com.codeborne.selenide.Condition.hasText; diff --git a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectPermissionsTest.java b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectPermissionsTest.java index 2184a9a9506..410df9fa171 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectPermissionsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectPermissionsTest.java @@ -27,8 +27,8 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.ProjectPermissionsPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.ProjectPermissionsPage; import util.user.UserRule; import static util.ItUtils.projectDir; diff --git a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectQualityGatePageTest.java b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectQualityGatePageTest.java index 438d239d6c9..6a3bdbbe8bc 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectQualityGatePageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectQualityGatePageTest.java @@ -33,8 +33,8 @@ import org.sonar.wsclient.qualitygate.QualityGateClient; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.qualitygate.SelectWsRequest; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.ProjectQualityGatePage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.ProjectQualityGatePage; import static util.ItUtils.newAdminWsClient; diff --git a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectVisibilityPageTest.java b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectVisibilityPageTest.java index 438d2ea7a36..d5b4b12baaf 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectVisibilityPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectVisibilityPageTest.java @@ -31,8 +31,8 @@ import org.sonarqube.ws.WsComponents; import org.sonarqube.ws.client.component.SearchProjectsRequest; import org.sonarqube.ws.client.permission.RemoveGroupWsRequest; import org.sonarqube.ws.client.project.UpdateVisibilityRequest; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.ProjectsManagementPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.ProjectsManagementPage; import util.user.UserRule; import static org.assertj.core.api.Assertions.assertThat; diff --git a/tests/src/test/java/org/sonarqube/tests/projectEvent/ProjectActivityPageTest.java b/tests/src/test/java/org/sonarqube/tests/projectEvent/ProjectActivityPageTest.java index d6514a930f0..7261e43d083 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectEvent/ProjectActivityPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectEvent/ProjectActivityPageTest.java @@ -27,9 +27,9 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.ProjectActivityPage; -import org.sonarqube.pageobjects.ProjectAnalysisItem; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.ProjectActivityPage; +import org.sonarqube.qa.util.pageobjects.ProjectAnalysisItem; import util.user.UserRule; import static util.ItUtils.projectDir; diff --git a/tests/src/test/java/org/sonarqube/tests/projectSearch/LeakProjectsPageTest.java b/tests/src/test/java/org/sonarqube/tests/projectSearch/LeakProjectsPageTest.java index 3bbe47d1174..b09816c222c 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectSearch/LeakProjectsPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectSearch/LeakProjectsPageTest.java @@ -33,7 +33,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonarqube.tests.Tester; import org.sonarqube.ws.Organizations.Organization; -import org.sonarqube.pageobjects.projects.ProjectsPage; +import org.sonarqube.qa.util.pageobjects.projects.ProjectsPage; import static com.codeborne.selenide.WebDriverRunner.url; import static java.util.Arrays.asList; diff --git a/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java b/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java index cdd2e9b97d2..1a9b5a4a0a4 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectSearch/ProjectsPageTest.java @@ -27,8 +27,8 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.RuleChain; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.projects.ProjectsPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.projects.ProjectsPage; import org.sonarqube.tests.Category1Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.WsUsers; diff --git a/tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateUiTest.java index fc846cb244f..02e99e90a88 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateUiTest.java @@ -27,8 +27,8 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.openqa.selenium.By; -import org.sonarqube.pageobjects.ProjectDashboardPage; -import org.sonarqube.pageobjects.QualityGatePage; +import org.sonarqube.qa.util.pageobjects.ProjectDashboardPage; +import org.sonarqube.qa.util.pageobjects.QualityGatePage; import org.sonarqube.tests.Category6Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.Organizations; diff --git a/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateUiTest.java index 132e081054c..5c342390d41 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateUiTest.java @@ -31,8 +31,8 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.openqa.selenium.By; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.ProjectActivityPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.ProjectActivityPage; import org.sonarqube.tests.Category1Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.WsProjects.CreateWsResponse.Project; diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java index 1414b129683..5a55561549c 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java @@ -27,9 +27,9 @@ import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.QualityProfilePage; -import org.sonarqube.pageobjects.RulesPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.QualityProfilePage; +import org.sonarqube.qa.util.pageobjects.RulesPage; import org.sonarqube.tests.Category6Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.Organizations.Organization; diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java index f67a20b0acd..5ad0041e602 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/QualityProfilesUiTest.java @@ -28,7 +28,7 @@ import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.Navigation; import org.sonarqube.tests.Category4Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.client.PostRequest; diff --git a/tests/src/test/java/org/sonarqube/tests/rule/RulesPageTest.java b/tests/src/test/java/org/sonarqube/tests/rule/RulesPageTest.java index 07e76dcc2c6..527dbe423ce 100644 --- a/tests/src/test/java/org/sonarqube/tests/rule/RulesPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/rule/RulesPageTest.java @@ -23,7 +23,7 @@ import com.sonar.orchestrator.Orchestrator; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.RulesPage; +import org.sonarqube.qa.util.pageobjects.RulesPage; import org.sonarqube.tests.Category2Suite; import org.sonarqube.tests.Tester; diff --git a/tests/src/test/java/org/sonarqube/tests/serverSystem/SystemInfoTest.java b/tests/src/test/java/org/sonarqube/tests/serverSystem/SystemInfoTest.java index ae11a552e85..60065d71954 100644 --- a/tests/src/test/java/org/sonarqube/tests/serverSystem/SystemInfoTest.java +++ b/tests/src/test/java/org/sonarqube/tests/serverSystem/SystemInfoTest.java @@ -27,7 +27,7 @@ import org.apache.commons.io.FileUtils; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.SystemInfoPage; +import org.sonarqube.qa.util.pageobjects.SystemInfoPage; import org.sonarqube.tests.Category4Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.client.GetRequest; diff --git a/tests/src/test/java/org/sonarqube/tests/settings/PropertySetsTest.java b/tests/src/test/java/org/sonarqube/tests/settings/PropertySetsTest.java index d30b68168e3..a6241c79374 100644 --- a/tests/src/test/java/org/sonarqube/tests/settings/PropertySetsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/settings/PropertySetsTest.java @@ -34,8 +34,8 @@ import org.sonarqube.ws.Settings; import org.sonarqube.ws.client.setting.SetRequest; import org.sonarqube.ws.client.setting.SettingsService; import org.sonarqube.ws.client.setting.ValuesRequest; -import org.sonarqube.pageobjects.Navigation; -import org.sonarqube.pageobjects.settings.SettingsPage; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.settings.SettingsPage; import util.user.UserRule; import static com.google.common.collect.Lists.newArrayList; diff --git a/tests/src/test/java/org/sonarqube/tests/settings/SettingsTestRestartingOrchestrator.java b/tests/src/test/java/org/sonarqube/tests/settings/SettingsTestRestartingOrchestrator.java index 60d690257e9..19c40338289 100644 --- a/tests/src/test/java/org/sonarqube/tests/settings/SettingsTestRestartingOrchestrator.java +++ b/tests/src/test/java/org/sonarqube/tests/settings/SettingsTestRestartingOrchestrator.java @@ -27,8 +27,8 @@ import org.junit.After; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonarqube.pageobjects.EncryptionPage; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.EncryptionPage; +import org.sonarqube.qa.util.pageobjects.Navigation; import util.user.UserRule; import static com.codeborne.selenide.Condition.visible; diff --git a/tests/src/test/java/org/sonarqube/tests/ui/SourceViewerTest.java b/tests/src/test/java/org/sonarqube/tests/ui/SourceViewerTest.java index 64ff1451740..f37daa3229f 100644 --- a/tests/src/test/java/org/sonarqube/tests/ui/SourceViewerTest.java +++ b/tests/src/test/java/org/sonarqube/tests/ui/SourceViewerTest.java @@ -25,7 +25,7 @@ import org.sonarqube.tests.Category4Suite; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.Navigation; import static com.codeborne.selenide.Condition.exist; import static com.codeborne.selenide.Selenide.$; diff --git a/tests/src/test/java/org/sonarqube/tests/ui/UiTest.java b/tests/src/test/java/org/sonarqube/tests/ui/UiTest.java index 040498df101..050960d843f 100644 --- a/tests/src/test/java/org/sonarqube/tests/ui/UiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/ui/UiTest.java @@ -29,7 +29,7 @@ import org.junit.ClassRule; import org.junit.Test; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.Navigation; import util.ItUtils; import static com.codeborne.selenide.Condition.exist; diff --git a/tests/src/test/java/org/sonarqube/tests/user/BaseIdentityProviderTest.java b/tests/src/test/java/org/sonarqube/tests/user/BaseIdentityProviderTest.java index 65cd095d285..bcd7384dfae 100644 --- a/tests/src/test/java/org/sonarqube/tests/user/BaseIdentityProviderTest.java +++ b/tests/src/test/java/org/sonarqube/tests/user/BaseIdentityProviderTest.java @@ -22,7 +22,6 @@ package org.sonarqube.tests.user; import com.google.common.base.Joiner; import com.google.common.base.Optional; import com.sonar.orchestrator.Orchestrator; -import org.sonarqube.tests.Category4Suite; import java.io.File; import org.apache.commons.io.FileUtils; import org.junit.After; @@ -30,10 +29,11 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.tests.Category4Suite; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.user.CreateRequest; -import org.sonarqube.pageobjects.Navigation; import util.user.UserRule; import util.user.Users; diff --git a/tests/src/test/java/org/sonarqube/tests/user/ForceAuthenticationTest.java b/tests/src/test/java/org/sonarqube/tests/user/ForceAuthenticationTest.java index 1f0ae8f71ee..7d731b7b773 100644 --- a/tests/src/test/java/org/sonarqube/tests/user/ForceAuthenticationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/user/ForceAuthenticationTest.java @@ -34,7 +34,7 @@ import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsConnector; import org.sonarqube.ws.client.WsRequest; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.Navigation; import static org.assertj.core.api.Assertions.assertThat; import static org.sonarqube.ws.client.WsRequest.Method.GET; diff --git a/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java b/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java index 7c17b06599a..8dc84a3ad2e 100644 --- a/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java @@ -26,8 +26,8 @@ import org.junit.After; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.LoginPage; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.LoginPage; +import org.sonarqube.qa.util.pageobjects.Navigation; import org.sonarqube.tests.Category4Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.WsUserTokens; diff --git a/tests/src/test/java/org/sonarqube/tests/user/MyAccountPageTest.java b/tests/src/test/java/org/sonarqube/tests/user/MyAccountPageTest.java index de2c4a992d3..58877d221e2 100644 --- a/tests/src/test/java/org/sonarqube/tests/user/MyAccountPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/user/MyAccountPageTest.java @@ -21,15 +21,15 @@ package org.sonarqube.tests.user; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import org.sonarqube.tests.Category4Suite; import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; +import org.sonarqube.qa.util.pageobjects.Navigation; +import org.sonarqube.tests.Category4Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.WsUsers.CreateWsResponse.User; import org.sonarqube.ws.client.PostRequest; -import org.sonarqube.pageobjects.Navigation; import static com.codeborne.selenide.Condition.text; import static com.codeborne.selenide.Condition.visible; diff --git a/tests/src/test/java/org/sonarqube/tests/user/OAuth2IdentityProviderTest.java b/tests/src/test/java/org/sonarqube/tests/user/OAuth2IdentityProviderTest.java index 65312825703..62eb79412c2 100644 --- a/tests/src/test/java/org/sonarqube/tests/user/OAuth2IdentityProviderTest.java +++ b/tests/src/test/java/org/sonarqube/tests/user/OAuth2IdentityProviderTest.java @@ -32,7 +32,7 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.qa.util.pageobjects.Navigation; import org.sonarqube.tests.Category4Suite; import org.sonarqube.tests.Tester; import org.sonarqube.ws.WsUsers.SearchWsResponse.User; diff --git a/tests/src/test/java/org/sonarqube/tests/user/RealmAuthenticationTest.java b/tests/src/test/java/org/sonarqube/tests/user/RealmAuthenticationTest.java index 12de1b740af..f1ed633686c 100644 --- a/tests/src/test/java/org/sonarqube/tests/user/RealmAuthenticationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/user/RealmAuthenticationTest.java @@ -36,7 +36,7 @@ import org.sonar.wsclient.base.HttpException; import org.sonar.wsclient.connectors.HttpClient4Connector; import org.sonar.wsclient.services.AuthenticationQuery; import org.sonar.wsclient.user.UserParameters; -import org.sonarqube.pageobjects.SystemInfoPage; +import org.sonarqube.qa.util.pageobjects.SystemInfoPage; import org.sonarqube.tests.Tester; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; diff --git a/tests/src/test/java/util/selenium/SeleneseRunner.java b/tests/src/test/java/util/selenium/SeleneseRunner.java index 96cc4e609a2..67b2ad67fe8 100644 --- a/tests/src/test/java/util/selenium/SeleneseRunner.java +++ b/tests/src/test/java/util/selenium/SeleneseRunner.java @@ -39,7 +39,7 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.logging.LogEntries; import org.openqa.selenium.logging.LogEntry; import org.openqa.selenium.logging.LogType; -import org.sonarqube.pageobjects.SelenideConfig; +import org.sonarqube.qa.util.SelenideConfig; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull;