aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-qa-util
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2018-04-06 17:22:28 +0200
committerSonarTech <sonartech@sonarsource.com>2018-04-09 20:20:45 +0200
commit3136ecae882db65db856b5f6f9e0a19a9781763f (patch)
tree3ce431cc3477a636b59fa66aedbb7a90564085ad /server/sonar-qa-util
parent18f6091bb9b381012013bf0fdf261a2300da8926 (diff)
downloadsonarqube-3136ecae882db65db856b5f6f9e0a19a9781763f.tar.gz
sonarqube-3136ecae882db65db856b5f6f9e0a19a9781763f.zip
Fix QA
Diffstat (limited to 'server/sonar-qa-util')
-rw-r--r--server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java10
-rw-r--r--server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java23
-rw-r--r--server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/PropertySetInput.java4
-rw-r--r--server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/settings/SettingsPage.java14
4 files changed, 42 insertions, 9 deletions
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java
index 2609faaa7c0..7378ffd1860 100644
--- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java
+++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java
@@ -22,6 +22,7 @@ package org.sonarqube.qa.util;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
+import javax.annotation.Nullable;
import org.assertj.core.api.Assertions;
import org.sonarqube.ws.Common;
import org.sonarqube.ws.Organizations.Organization;
@@ -55,10 +56,15 @@ public class QProfileTester {
}
@SafeVarargs
- public final QualityProfile createXooProfile(Organization organization, Consumer<CreateRequest>... populators) {
+ public final QualityProfile createXooProfile(Consumer<CreateRequest>... populators) {
+ return createXooProfile(null, populators);
+ }
+
+ @SafeVarargs
+ public final QualityProfile createXooProfile(@Nullable Organization organization, Consumer<CreateRequest>... populators) {
int id = ID_GENERATOR.getAndIncrement();
CreateRequest request = new CreateRequest()
- .setOrganization(organization.getKey())
+ .setOrganization(organization == null ? null : organization.getKey())
.setLanguage("xoo")
.setName("Profile" + id);
stream(populators).forEach(p -> p.accept(request));
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
index 073df461b8b..a0266da622a 100644
--- 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
@@ -55,7 +55,7 @@ public class Navigation {
driver.manage().deleteAllCookies();
clearStorage(d -> d.getLocalStorage().clear());
clearStorage(d -> d.getSessionStorage().clear());
- clearStorage(d -> Selenide.clearBrowserLocalStorage());
+ clearBrowserLocalStorage();
return Selenide.open(path, Navigation.class);
}
@@ -69,6 +69,19 @@ public class Navigation {
}
}
+ /**
+ * Do not call {@link #clearStorage(Consumer)} for {@link Selenide#clearBrowserLocalStorage} as it's failing on Firefox 46
+ */
+ private static void clearBrowserLocalStorage() {
+ try {
+ Selenide.clearBrowserLocalStorage();
+ } 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);
}
@@ -85,10 +98,18 @@ public class Navigation {
return open("/projects?" + query, ProjectsPage.class);
}
+ public ProjectsPage openExploreProjects() {
+ return open("/explore/projects", ProjectsPage.class);
+ }
+
public IssuesPage openIssues() {
return open("/issues", IssuesPage.class);
}
+ public IssuesPage openExploreIssues() {
+ return open("/explore/issues", IssuesPage.class);
+ }
+
public IssuesPage openIssues(String organization) {
return open("/organizations/" + organization + "/issues", IssuesPage.class);
}
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
index 759f7189a71..46f1ac6201a 100644
--- 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
@@ -40,8 +40,8 @@ public class PropertySetInput {
}
public PropertySetInput save() {
- elt.find(".js-save-changes").click();
- elt.find(".js-save-changes").shouldNot(Condition.exist);
+ elt.find(".button-success").click();
+ elt.find(".button-success").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
index 9bb53d9b50f..f55d3edfa9d 100644
--- 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
@@ -116,12 +116,12 @@ public class SettingsPage {
}
public SettingsPage clickOnCancel(String settingKey) {
- Selenide.$("[data-key=\"" + settingKey + "\"]").find(byText("Cancel")).click();
+ click(Selenide.$("[data-key=\"" + settingKey + "\"]").find(byText("Cancel")));
return this;
}
public SettingsPage removeFirstValue(String settingKey) {
- Selenide.$("[data-key=\"" + settingKey + "\"]").find(".button.js-remove-value.button-icon").click();
+ click(Selenide.$("[data-key=\"" + settingKey + "\"]").find(".js-remove-value"));
return this;
}
@@ -133,8 +133,8 @@ public class SettingsPage {
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);
+ setting.find(".button-success").click();
+ setting.find(".button-success").shouldNot(Condition.exist);
return this;
}
@@ -142,4 +142,10 @@ public class SettingsPage {
SelenideElement setting = Selenide.$(".settings-definition[data-key=\"" + settingKey + "\"]");
return new PropertySetInput(setting);
}
+
+ private void click(SelenideElement selenideElement){
+ // FIXME Temporary fix to correctly scroll in Firefox 46
+ Selenide.executeJavaScript("arguments[0].click()", selenideElement);
+ }
+
}