Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 3da35002 authored by rui rodrigues's avatar rui rodrigues
Browse files

Merge branch 'SIMPL-3539' into 'develop'

Complete The Compliance Review Body Form and The Save Button is Enabled test

See merge request simpl/pso/pso-test/pso-test-automation!16
parents a95b80eb 2d1aa929
No related branches found
No related tags found
No related merge requests found
Pipeline #195897 passed with warnings
package configuration.ui.data.simplOpen;
public class Product {
public static final String BACKPACK_NAME = "Sauce Labs Backpack";
}
......@@ -3,4 +3,7 @@ package configuration.ui.data.simplOpen;
public class Wizard {
public static final String URL = "https://sd-creation-wizard.uatpso.com";
public static final String FILE_PATH = "simplOpen/input-shacl-file.ttl";
public static final String AGE = "30";
public static final String NAME = "Peter";
public static final String BIRTH_DATE = "01/01/1990";
}
package configuration.ui.locators.simplOpen;
public class Wizard {
public static final String GET_STARTED_BUTTON= "Get Started";
public static final String SELECT_SHACL_TEXT=" Select a SHACL shape or ";
public static final String UPLOAD_TEXT="a[style='cursor: pointer;']:has-text('Upload')";
public static final String WIDGET_CLASS=".mat-card.mat-focus-indicator.info-message";
public static final String CHOOSE_FILE_BUTTON="input[type='file']";
public static final String FILE_NAME_DISPLAYED=".form-control.ng-touched.ng-dirty.ng-valid";
public static final String UPLOAD_BUTTON="//span[contains(text(), 'Upload')]";
public static final String COMPLETE_PERSON_FORM=".mat-card.mat-focus-indicator.mat-elevation-z4";
public static final String GET_STARTED_BUTTON = "Get Started";
public static final String SELECT_SHACL_TEXT = " Select a SHACL shape or ";
public static final String UPLOAD_TEXT = "a[style='cursor: pointer;']:has-text('Upload')";
public static final String WIDGET_CLASS = ".mat-card.mat-focus-indicator.info-message";
public static final String CHOOSE_FILE_BUTTON = "input[type='file']";
public static final String FILE_NAME_DISPLAYED = ".form-control.ng-touched.ng-dirty.ng-valid";
public static final String UPLOAD_BUTTON = "//span[contains(text(), 'Upload')]";
public static final String COMPLETE_PERSON_FORM = ".mat-card.mat-focus-indicator.mat-elevation-z4";
public static final String AGE_FIELD = "//input[@id='mat-input-0']";
public static final String NAME_FIELD = "//input[@id='mat-input-1']";
public static final String GENDER_FIELD = "//span[@class='mat-select-placeholder mat-select-min-line ng-tns-c76-3 ng-star-inserted']";
public static final String MALE_OPTION = "//span[@class='mat-option-text'][normalize-space()='male']";
public static final String BIRTH_DATE_FIELD = "//input[@id='mat-input-2']";
public static final String SAVE_BUTTON = "//span[contains(text(), 'Save')]";
}
......@@ -18,6 +18,8 @@ public class UiSetup {
return page;
}
public static Browser getBrowser() { return browser; }
public static Scenario getScenario() {
return scenario;
}
......@@ -61,9 +63,9 @@ public class UiSetup {
/**
* Returns a Locator object that filters by the specified text.
*
* @param page The Playwright Page object.
* @param page The Playwright Page object.
* @param selector The CSS selector to locate the element.
* @param text The text to filter the locator by.
* @param text The text to filter the locator by.
* @return Locator with the text filter applied.
*/
public static Locator getLocatorWithText(Page page, String selector, String text) {
......
......@@ -11,7 +11,7 @@ Feature: Wizard
And the information select a SHACL shape or Upload should be displayed
@TCW02 @SIMPL-1019 @SIMPL-1020 @SIMPL-1022 @SIMPL-1024
@TCW02 @SIMPL-1019 @SIMPL-1020 @SIMPL-1022
Scenario: File Upload and Displaying of Complete Person Form
Given the file selection dialog box is visible
And the user clicks the Upload button from the widget
......@@ -31,4 +31,17 @@ Feature: Wizard
And the user drags and drops the file
And the file name is visible in the upload widget
When the user clicks the upload button from the Upload Shape
Then the Complete Person Form is displayed
\ No newline at end of file
Then the Complete Person Form is displayed
@TCW04 @SIMPL-1024 @SIMPL-1025
Scenario: Complete The Compliance Review Body Form and The Save Button is Enabled
Given the file selection dialog box is visible
And the user clicks the Upload button from the widget
And the user clicks the Choose file button
And the user selects a .tll file
And the file name is visible in the upload widget
When the user clicks the upload button from the Upload Shape
And the Complete Person Form is displayed
And the user fills in the Compliance Review Body Form
And the Save button is enabled
Then the user clicks the Save button
\ No newline at end of file
package stepDefinitions.ui.simplOpen;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Locator;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.options.FilePayload;
import framework.common.Config;
import com.microsoft.playwright.BrowserContext;
import framework.ui.UiSetup;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static configuration.ui.data.simplOpen.Wizard.FILE_PATH;
import static configuration.ui.data.simplOpen.Wizard.URL;
import static configuration.ui.data.simplOpen.Wizard.*;
import static configuration.ui.locators.simplOpen.Wizard.*;
public class WizardSteps {
private final UiSetup uiSetup = new UiSetup();
private final Page page = UiSetup.getPage();
private Path downloadDir;
@Given("the user is on the SD Wizard")
......@@ -92,7 +96,7 @@ public class WizardSteps {
}
@Then("the Complete Person Form is displayed")
public void the_complete_person_form_is_displayed() throws InterruptedException {
public void the_complete_person_form_is_displayed() {
page.locator(COMPLETE_PERSON_FORM).isVisible();
uiSetup.attachScreenshot();
}
......@@ -112,4 +116,31 @@ public class WizardSteps {
dropArea.hover();
page.mouse().up();
}
@And("the user fills in the Compliance Review Body Form")
public void theUserFillsInTheComplianceReviewBodyForm() {
page.locator(AGE_FIELD).fill(AGE);
page.locator(NAME_FIELD).fill(NAME);
page.locator(GENDER_FIELD).click();
page.locator(MALE_OPTION).click();
page.locator(BIRTH_DATE_FIELD).fill(BIRTH_DATE);
}
@And("the Save button is enabled")
public void theSaveButtonIsEnabled() {
boolean isEnabled = page.locator(SAVE_BUTTON).isEnabled();
if (!isEnabled) {
throw new RuntimeException("Save button is not enabled");
}
}
@Then("the user clicks the Save button")
public void theUserClicksTheSaveButton() {
page.locator(SAVE_BUTTON).click();
uiSetup.attachScreenshot();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment