* Test updated for SONAR-3570 and SONAR-5923
*/
@Test
- public void project_deletion() throws Exception {
+ public void project_deletion() {
String projectAdminUser = "project-deletion-with-admin-permission-on-project";
SonarClient adminClient = orchestrator.getServer().adminWsClient();
try {
adminClient.permissionClient().addPermission(
PermissionParameters.create().user(projectAdminUser).component("sample").permission("admin"));
- // Use the old runner because it fails with the new Selenium runner
- orchestrator.executeSelenese(
+ new SeleneseTest(
Selenese.builder().setHtmlTestsInClasspath("project-deletion", "/administration/suite/ProjectAdministrationTest/project-deletion/project-deletion.html").build()
- );
+ ).runOn(orchestrator);
} finally {
adminClient.userClient().deactivate(projectAdminUser);
}
// SONAR-4203
@Test
- public void delete_version_of_multimodule_project() throws Exception {
+ public void delete_version_of_multimodule_project() {
GregorianCalendar today = new GregorianCalendar();
SonarRunner build = SonarRunner.create(projectDir("shared/xoo-multi-modules-sample"))
.setProperty("sonar.dynamicAnalysis", "false")
// SONAR-3326
@Test
- public void display_alerts_correctly_in_history_page() throws Exception {
+ public void display_alerts_correctly_in_history_page() {
QualityGateClient qgClient = orchestrator.getServer().adminWsClient().qualityGateClient();
QualityGate qGate = qgClient.create("AlertsForHistory");
qgClient.setDefault(qGate.id());
.setHtmlTestsInClasspath("display-alerts-history-page",
"/administration/suite/ProjectAdministrationTest/display-alerts-history-page/should-display-alerts-correctly-history-page.html"
).build();
- // Use the old runner because it fails with the new Selenium runner
- orchestrator.executeSelenese(selenese);
+ new SeleneseTest(selenese).runOn(orchestrator);
qgClient.unsetDefault();
qgClient.destroy(qGate.id());
* SONAR-1352
*/
@Test
- public void display_period_alert_on_project_dashboard() throws Exception {
+ public void display_period_alert_on_project_dashboard() {
QualityGateClient qgClient = orchestrator.getServer().adminWsClient().qualityGateClient();
QualityGate qGate = qgClient.create("AlertsForDashboard");
qgClient.createCondition(NewCondition.create(qGate.id()).metricKey("lines").operator("LT").warningThreshold("0").errorThreshold("10")
"/administration/suite/ProjectAdministrationTest/project-update-keys/bulk-update-impossible-because-no-match.html",
"/administration/suite/ProjectAdministrationTest/project-update-keys/bulk-update-success.html"
).build();
- // Use the old runner because it fails with the new Selenium runner
- orchestrator.executeSelenese(selenese);
+ new SeleneseTest(selenese).runOn(orchestrator);
}
/**
"/administration/suite/ProjectAdministrationTest/project-update-keys/fine-grained-update-impossible.html",
"/administration/suite/ProjectAdministrationTest/project-update-keys/fine-grained-update-success.html"
).build();
- // Use the old runner because it fails with the new Selenium runner
- orchestrator.executeSelenese(selenese);
+ new SeleneseTest(selenese).runOn(orchestrator);
}
/**
}
public LazyShould should() {
- return new LazyShould(this, Retry._5_SECONDS, true);
+ return new LazyShould(this, Retry._30_SECONDS, true);
}
public void fill(final CharSequence text) {
public LazyShould contain(final String text) {
return verify(
- doesOrNot("contain(") + text + ")",
+ doesOrNot("contain") + "(" + text + ")",
new Predicate<List<WebElement>>() {
@Override
public boolean apply(List<WebElement> elements) {
class Retry {
public static final Retry _30_SECONDS = new Retry(30, SECONDS);
- public static final Retry _5_SECONDS = new Retry(5, SECONDS);
private final long timeoutInMs;
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.selenium.Selenese;
+import org.assertj.core.util.Strings;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import static java.util.Objects.requireNonNull;
import static java.util.regex.Pattern.DOTALL;
import static org.assertj.core.api.Assertions.assertThat;
-import static selenium.Retry._5_SECONDS;
+import static selenium.Retry._30_SECONDS;
public class SeleneseTest {
private final Selenese suite;
return this;
case "assertTextPresent":
assertTextPresent(param1);
+ return this;
case "assertTextNotPresent":
assertTextNotPresent(param1);
return this;
assertLocation(param1);
return this;
case "waitForElementPresent":
- waitForElementPresent(param1);
+ waitForElementPresent(param1, param2);
return this;
case "waitForVisible":
waitForVisible(param1);
confirm(param1);
return this;
case "setTimeout":
+ case "pause":
// Ignore
return this;
}
private LazyDomElement find(String selector) {
selector = replacePlaceholders(selector);
- if (selector.startsWith("link=")) {
+ if (selector.startsWith("link=") || selector.startsWith("Link=")) {
return find("a").withText(selector.substring(5));
}
}
System.out.println(" - selectFrame(" + id + ")");
- _5_SECONDS.execute(new Runnable() {
+ _30_SECONDS.execute(new Runnable() {
@Override
public void run() {
driver.switchTo().frame(id);
find("body").should().not().contain(text);
}
- private void waitForElementPresent(String selector) {
- find(selector).should().exist();
+ private void waitForElementPresent(String selector, String text) {
+ if (Strings.isNullOrEmpty(text)) {
+ find(selector).should().exist();
+ } else {
+ find(selector).withText(text).should().exist();
+ }
}
private void waitForVisible(String selector) {
private void confirm(final String message) {
System.out.println(" - confirm(" + message + ")");
- _5_SECONDS.execute(new Runnable() {
+ _30_SECONDS.execute(new Runnable() {
@Override
public void run() {
driver.switchTo().alert().accept();
<td>/sonar/dashboard/index/sample</td>
<td></td>
</tr>
+ <tr>
+ <td>click</td>
+ <td>css=#context-navigation .navbar-admin-link</td>
+ <td></td>
+ </tr>
<tr>
<td>waitForElementPresent</td>
<td>link=History</td>
<td>/sonar/dashboard/index/sample</td>
<td></td>
</tr>
+<tr>
+ <td>click</td>
+ <td>css=#context-navigation .navbar-admin-link</td>
+ <td></td>
+</tr>
<tr>
<td>waitForElementPresent</td>
<td>link=Deletion</td>
<td></td>
</tr>
<tr>
- <td>waitForElementPresent</td>
- <td>link=Update Key</td>
- <td></td>
+ <td>click</td>
+ <td>css=#context-navigation .navbar-admin-link</td>
+ <td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample</td>
<td></td>
</tr>
+ <tr>
+ <td>click</td>
+ <td>css=#context-navigation .navbar-admin-link</td>
+ <td></td>
+ </tr>
<tr>
<td>waitForElementPresent</td>
<td>link=Update Key</td>
<td>/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample</td>
<td></td>
</tr>
+ <tr>
+ <td>click</td>
+ <td>css=#context-navigation .navbar-admin-link</td>
+ <td></td>
+ </tr>
<tr>
<td>waitForElementPresent</td>
<td>link=Update Key</td>
<td>/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample</td>
<td></td>
</tr>
+<tr>
+ <td>click</td>
+ <td>css=#context-navigation .navbar-admin-link</td>
+ <td></td>
+</tr>
<tr>
<td>waitForElementPresent</td>
<td>link=Update Key</td>
<td>/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample</td>
<td></td>
</tr>
+ <tr>
+ <td>click</td>
+ <td>css=#context-navigation .navbar-admin-link</td>
+ <td></td>
+ </tr>
<tr>
<td>waitForElementPresent</td>
<td>link=Update Key</td>
<td>/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample</td>
<td></td>
</tr>
+ <tr>
+ <td>click</td>
+ <td>css=#context-navigation .navbar-admin-link</td>
+ <td></td>
+ </tr>
<tr>
<td>waitForElementPresent</td>
<td>link=Update Key</td>