Skip to content

Commit

Permalink
Merge pull request #68 from dzmitryrak/feature/SSC-66-ADD-VALIDATE-ALERT
Browse files Browse the repository at this point in the history
Add a new method for work with alerts
  • Loading branch information
dzmitryrak committed Mar 17, 2023
2 parents 95859b5 + 68da7d0 commit 5db61e9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,4 @@
<version>${apache.common.version}</version>
</dependency>
</dependencies>
</project>
</project>
15 changes: 15 additions & 0 deletions src/main/java/io/github/dzmitryrak/pages/BasePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.time.Duration;

import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$;

@Log4j2
Expand All @@ -18,6 +19,7 @@ public abstract class BasePage {
*
*/
public static Duration timeout = Duration.ofSeconds(20);
private final By ALERT_DIALOG = By.xpath("//div[@role='alertdialog']");

protected final String ACTIVE_TAB_LOCATOR = "//*[contains(@class,'windowViewMode') and contains(@class,'active')]";
protected ElementHelper sfHelper;
Expand All @@ -36,4 +38,17 @@ protected void clickJS(By locator) {
log.debug("JS click to element using locator {}", locator);
Selenide.executeJavaScript("arguments[0].click();", $(locator));
}

/**
* Get all alert messages on NewObjectModal.
* log alert message
* @return current instance of NewObjectModal
*/
@Step("Get Alert Messages")
public String getAlert() {
$(ALERT_DIALOG).shouldBe(visible);
String alertMessage = $(ALERT_DIALOG).shouldBe(visible).getText();
log.info("Popup Alert Message: {}", alertMessage);
return alertMessage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.github.dzmitryrak.tests;

import io.github.dzmitryrak.tests.base.BaseTest;
import org.testng.annotations.Test;
import static org.testng.Assert.assertTrue;

public class ValidateAlertDialogTest extends BaseTest {
@Test(description = "Check Success alert")
public void tableValidation() {
loginPage.open().login(USERNAME, PASSWORD);
String alertMessage = listView
.open("Case")
.actions()
.newObject()
.enterData("Case Origin", "Phone")
.save()
.getAlert();
assertTrue(alertMessage.contains("Success"));
}
}

0 comments on commit 5db61e9

Please sign in to comment.