Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
Add smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitakovaliov92 committed Jul 18, 2024
1 parent f4cc3ab commit d6927b2
Show file tree
Hide file tree
Showing 26 changed files with 568 additions and 27 deletions.
2 changes: 1 addition & 1 deletion profiles/pdf4wcag-smoke.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Smoke Suite">
<suite name="Smoke Suite" thread-count="3" parallel="classes">
<listeners>
<listener class-name="com.duallab.verapdf.utils.Pdf4WcagAutoRetryTransformer"/>
</listeners>
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/duallab/verapdf/base/AbstractElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ public <R, E extends Throwable> T assertResult(FunctionWithThrowing<T, R, E> toC
return thisAsT;
}

public <R, E extends Throwable> R applyShortcut(FunctionWithThrowing<T, R, E> shortcut) throws E {
T thisAsT = (T) this;
return shortcut.apply(thisAsT);
}

@FunctionalInterface
public interface ConsumerWithThrowing<T, E extends Throwable> {
void accept(T t) throws E;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.TextCheck;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.Properties;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.DesiredCapabilities;

public abstract class AbstractPdf4WcagSelenideConfig {

Expand Down Expand Up @@ -42,8 +41,7 @@ public static void setupStaticContext(String propertyFile, String baseUrlPropert
() -> {
capabilities.setBrowserName(Browsers.CHROME);
chromeOptions = new ChromeOptions()
// Enable indication that browser is controlled by automation
.addArguments("--enable-automation")
.addArguments("--headless=new")
// The /dev/shm partition is too small in certain VM environments, causing Chrome to fail
// or crash (see http://crbug.com/715363).
// Use this flag to work around this issue (a temporary directory will always be used to
Expand All @@ -53,9 +51,7 @@ public static void setupStaticContext(String propertyFile, String baseUrlPropert
// process won't launch
.addArguments("--disable-gpu")
// Disable extensions
.addArguments("--disable-extensions")
// Enables web socket connections from the specified origins only. '*' allows any origin.
.addArguments("--remote-allow-origins=*");
.addArguments("--disable-extensions");
Configuration.browserCapabilities = chromeOptions;
},
() -> {
Expand Down Expand Up @@ -89,10 +85,6 @@ public static String getInitializedProperty(String propertyName) {
return testProperties.getProperty(propertyName);
}

public String getProperty(String propertyName) {
return AbstractPdf4WcagSelenideConfig.getInitializedProperty(propertyName);
}

public void retryWithCleanMechanism(Runnable start, Runnable clean, int retryCount, long sleep) {
int attempt = 1;
while (true) {
Expand All @@ -115,7 +107,7 @@ private static void readPropertyFile(Properties properties, String propertiesFil
try (InputStream is = Files.newInputStream(file.toPath())) {
properties.load(is);
} catch (IOException e) {
LOGGER.warn("I/O exception on editor properties reading", e);
LOGGER.warn("I/O exception on pdf4wcag properties reading", e);
}
}

Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/duallab/verapdf/blocks/AboutBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.duallab.verapdf.blocks;

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.duallab.verapdf.pages.AboutPage;
import io.qameta.allure.Step;

public final class AboutBlock extends AbstractBlock<AboutBlock, AboutPage> {

private static final SelenideElement ABOUT_HEADER = Selenide.$("#about");

public AboutBlock(AboutPage baseElement) {
super(baseElement);
}

@Step("Gets about header element")
public SelenideElement getAboutHeaderElement() {
return ABOUT_HEADER;
}
}
38 changes: 38 additions & 0 deletions src/main/java/com/duallab/verapdf/blocks/HomeBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.duallab.verapdf.blocks;

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.duallab.verapdf.pages.AboutPage;
import com.duallab.verapdf.pages.HomePage;
import com.duallab.verapdf.pages.PrivacyPolicyPage;
import com.duallab.verapdf.pages.UploadFilePage;
import io.qameta.allure.Step;

public final class HomeBlock extends AbstractBlock<HomeBlock, HomePage> {

private static final SelenideElement TRY_NOW_BUTTON = Selenide.$("#try-now-button");
private static final SelenideElement PRIVACY_POLICY_BUTTON = Selenide.$("a[href='/validate/privacy-policy']");
private static final SelenideElement READ_MORE_BUTTON = Selenide.$("a[href='/validate/about']");

public HomeBlock(HomePage baseElement) {
super(baseElement);
}

@Step("Clicks try now button")
public UploadFilePage goToUploadFilePage() {
TRY_NOW_BUTTON.click();
return UploadFilePage.openToUploadFromComputer();
}

@Step("Clicks privacy policy button")
public PrivacyPolicyPage clickPrivacyPolicyButton() {
PRIVACY_POLICY_BUTTON.click();
return PrivacyPolicyPage.open();
}

@Step("Clicks read more button")
public AboutPage clickReadMoreButton() {
READ_MORE_BUTTON.click();
return AboutPage.open();
}
}
55 changes: 55 additions & 0 deletions src/main/java/com/duallab/verapdf/blocks/PdfViewerBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.duallab.verapdf.blocks;

import com.codeborne.selenide.ElementsCollection;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.duallab.verapdf.blocks.dialog.ErrorDialog;
import com.duallab.verapdf.pages.PdfViewerPage;
import io.qameta.allure.Step;

public final class PdfViewerBlock extends AbstractBlock<PdfViewerBlock, PdfViewerPage> {

private static final SelenideElement RULE_ITEM = Selenide.$(".rule-item__chip");
private static final SelenideElement RULE_ITEM_CONTENT = Selenide.$(".rule-item_error");
private static final SelenideElement CHECK_ITEM = Selenide.$(".check-item");
private static final SelenideElement SELECTED_BOX = Selenide.$("div.pdf-bbox_selected");
private static final SelenideElement INFO_BUTTON = Selenide.$("button[aria-label='info']");
private static final ElementsCollection CONTEXT_TEXT = Selenide.$$(".content-text");

public PdfViewerBlock(PdfViewerPage baseElement) {
super(baseElement);
}

@Step("Expands rule item content")
public PdfViewerPage clickRuleItemContent() {
RULE_ITEM_CONTENT.click();
return getParentElement();
}

@Step("Clicks check item content")
public PdfViewerPage clickCheckItemContent() {
CHECK_ITEM.click();
return getParentElement();
}

@Step("Clicks info button")
public ErrorDialog clickInfoButton() {
INFO_BUTTON.click();
return ErrorDialog.openErrorDialog(getParentElement());
}

@Step("Gets rule item element")
public SelenideElement getRuleItemElement() {
return RULE_ITEM;
}

@Step("Gets content text elements")
public ElementsCollection getContextTextElements() {
return CONTEXT_TEXT;
}

@Step("Gets selected box element")
public SelenideElement getSelectedBoxElement() {
return SELECTED_BOX;
}
}
21 changes: 21 additions & 0 deletions src/main/java/com/duallab/verapdf/blocks/PrivacyPolicyBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.duallab.verapdf.blocks;

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.duallab.verapdf.pages.PrivacyPolicyPage;
import io.qameta.allure.Step;

public final class PrivacyPolicyBlock extends AbstractBlock<PrivacyPolicyBlock, PrivacyPolicyPage> {

private static final SelenideElement PRIVACY_POLICY_HEADER = Selenide.$("#privacy-policy");

public PrivacyPolicyBlock(PrivacyPolicyPage baseElement) {
super(baseElement);
}

@Step("Gets privacy policy element")
public SelenideElement getPrivacyPolicyHeaderElement() {
Selenide.switchTo().window(1);
return PRIVACY_POLICY_HEADER;
}
}
48 changes: 48 additions & 0 deletions src/main/java/com/duallab/verapdf/blocks/ResultSummaryBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.duallab.verapdf.blocks;

import com.codeborne.selenide.ElementsCollection;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.duallab.verapdf.pages.PdfViewerPage;
import com.duallab.verapdf.pages.ResultSummaryPage;
import io.qameta.allure.Step;

public final class ResultSummaryBlock extends AbstractBlock<ResultSummaryBlock, ResultSummaryPage> {

private static final SelenideElement JOB_FILENAME = Selenide.$(".job-filename");
private static final SelenideElement MACHINE_AND_HUMAN_PROFILE_NAME =
Selenide.$x("//p[text()='WCAG 2.2 Machine & Human (experimental)']");
private static final SelenideElement SUMMARY_RESULT = Selenide.$(".legend");
private static final SelenideElement INSPECT_ERRORS_BUTTON = Selenide.$x("//span[text()='Inspect errors']");
private static final ElementsCollection SUMMARY_LIST = Selenide.$$(".summary__list ul li");

public ResultSummaryBlock(ResultSummaryPage baseElement) {
super(baseElement);
}

@Step("Clicks inspect errors button")
public PdfViewerPage goToPdfViewerPage() {
INSPECT_ERRORS_BUTTON.click();
return PdfViewerPage.open();
}

@Step("Gets job file name element")
public SelenideElement getJobFilenameElement() {
return JOB_FILENAME;
}

@Step("Gets profile name element")
public SelenideElement getMachineAndHumanProfileNameElement() {
return MACHINE_AND_HUMAN_PROFILE_NAME;
}

@Step("Gets summary list elements")
public ElementsCollection getSummaryListElements() {
return SUMMARY_LIST;
}

@Step("Gets summary result element")
public SelenideElement getSummaryResultElement() {
return SUMMARY_RESULT;
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/duallab/verapdf/blocks/SettingsBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.duallab.verapdf.blocks;

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.duallab.verapdf.pages.ResultSummaryPage;
import com.duallab.verapdf.pages.SettingsPage;
import io.qameta.allure.Step;

public final class SettingsBlock extends AbstractBlock<SettingsBlock, SettingsPage> {

private static final SelenideElement VALIDATE_BUTTON = Selenide.$x("//span[text()='Validate']");

public SettingsBlock(SettingsPage baseElement) {
super(baseElement);
}

@Step("Clicks validate button")
public ResultSummaryPage goToResultSummaryPage() {
VALIDATE_BUTTON.click();
return ResultSummaryPage.open();
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/duallab/verapdf/blocks/UploadDropzoneBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.duallab.verapdf.blocks;

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.duallab.verapdf.pages.UploadFilePage;
import io.qameta.allure.Step;
import java.io.File;

public final class UploadDropzoneBlock extends AbstractBlock<UploadDropzoneBlock, UploadFilePage> {

private static final SelenideElement DROPZONE = Selenide.$("input[accept='application/pdf']");

public UploadDropzoneBlock(UploadFilePage baseElement) {
super(baseElement);
}

@Step("Uploads file")
public UploadFilePage uploadFile(File file) {
DROPZONE.uploadFile(file);
return getParentElement();
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/duallab/verapdf/blocks/UploadFileBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.duallab.verapdf.blocks;

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.duallab.verapdf.pages.SettingsPage;
import com.duallab.verapdf.pages.UploadFilePage;
import io.qameta.allure.Step;

public final class UploadFileBlock extends AbstractBlock<UploadFileBlock, UploadFilePage> {

private static final SelenideElement CONFIGURE_JOB_BUTTON = Selenide.$x("//span[text()='Configure job']");

public UploadFileBlock(UploadFilePage baseElement) {
super(baseElement);
}

@Step("Clicks configure job button")
public SettingsPage goToSettingsPage() {
CONFIGURE_JOB_BUTTON.click();
return SettingsPage.open();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.duallab.verapdf.blocks.dialog;

import com.duallab.verapdf.base.AbstractElement;
import com.duallab.verapdf.blocks.AbstractBlock;

public abstract class AbstractDialog<T, P extends AbstractElement<P>> extends AbstractBlock<T, P> {

protected AbstractDialog(P baseElement) {
super(baseElement);
}
}
37 changes: 37 additions & 0 deletions src/main/java/com/duallab/verapdf/blocks/dialog/ErrorDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.duallab.verapdf.blocks.dialog;

import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.duallab.verapdf.pages.PdfViewerPage;
import io.qameta.allure.Step;

public final class ErrorDialog extends AbstractDialog<ErrorDialog, PdfViewerPage> {

private static final SelenideElement DIALOG_TITLE = Selenide.$("#alert-dialog-title");
private static final SelenideElement DIALOG_DESCRIPTION = Selenide.$("#alert-dialog-description");
private static final SelenideElement CLOSE_BUTTON = Selenide.$("div[title='Close']");

private ErrorDialog(PdfViewerPage baseElement) {
super(baseElement);
}

public static ErrorDialog openErrorDialog(PdfViewerPage pdfViewerPage) {
return new ErrorDialog(pdfViewerPage);
}

@Step("Clicks close button")
public PdfViewerPage clickCloseButton() {
CLOSE_BUTTON.click();
return getParentElement();
}

@Step("Gets dialog title element")
public SelenideElement getDialogTitleElement() {
return DIALOG_TITLE;
}

@Step("Gets dialog description element")
public SelenideElement getDialogDescriptionElement() {
return DIALOG_DESCRIPTION;
}
}
Loading

0 comments on commit d6927b2

Please sign in to comment.