From 938ba76c116dfd5ee7c6f83aac229db089ebc797 Mon Sep 17 00:00:00 2001 From: Natalya Firstova Date: Tue, 15 May 2018 16:30:05 +0400 Subject: [PATCH] Update README --- README.md | 80 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 4dc07bd..102376b 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,16 @@ The name of the attribute corresponds to the `cuba-id` attribute of a DOM element that corresponds to the UI component. ```java + +import com.haulmont.masquerade.Wire +import com.haulmont.masquerade.base.Composite +import com.haulmont.masquerade.components.Button +import com.haulmont.masquerade.components.CheckBox +import com.haulmont.masquerade.components.Label +import com.haulmont.masquerade.components.LookupField +import com.haulmont.masquerade.components.PasswordField +import com.haulmont.masquerade.components.TextField + public class LoginWindow extends Composite { @Wire public TextField loginField; @@ -127,41 +137,59 @@ You can use all JUnit annotations to improve the tests. Also, it is possible to use a set of assertion methods provided by JUnit. ```java -@Test -public void login() { - // open URL of an application - open("http://localhost:8080/app"); +import com.company.uisample.web.ui.LoginWindow +import com.haulmont.masquerade.components.Untyped +import org.junit.Test + +import static com.codeborne.selenide.Selenide.close +import static com.codeborne.selenide.Selenide.open +import static com.haulmont.masquerade.Components._$ +import static com.haulmont.masquerade.Components.wire +import static com.haulmont.masquerade.Conditions.* + +class LoginUiTest { - // obtain UI object - LoginWindow loginWindow = _$(LoginWindow.class); - loginWindow.loginField - .shouldBe(EDITABLE) - .shouldBe(ENABLED); + @Test + void loginTest() { + // open URL of an application + open("http://localhost:8080/app") - // setting values - loginWindow.loginField.setValue("masquerade"); - loginWindow.passwordField.setValue("rulezzz"); + // obtain UI object + LoginWindow loginWindow = _$(LoginWindow.class) - loginWindow.rememberMeCheckBox.setChecked(true); + loginWindow.loginField + .shouldBe(EDITABLE) + .shouldBe(ENABLED) - // fluent asserts - loginWindow.welcomeLabelTest - .shouldBe(VISIBLE); + // setting values + loginWindow.with { + loginField.setValue("admin") + passwordField.setValue("admin") - loginWindow.loginSubmitButton - .shouldBe(VISIBLE) - .shouldBe(ENABLED) - .shouldHave(caption("Submit")); + rememberMeCheckBox.setChecked(true) + } - // get values from Component - String caption = loginWindow.loginSubmitButton.getCaption(); - boolean enabled = loginWindow.loginSubmitButton.is(ENABLED); + // fluent asserts + loginWindow.welcomeLabel + .shouldBe(VISIBLE) - Untyped loginFormLayout = wire(Untyped.class, "loginFormLayout"); - loginFormLayout.shouldBe(VISIBLE); + loginWindow.loginButton + .shouldBe(VISIBLE) + .shouldBe(ENABLED) + .shouldHave(caption("Submit")) - loginWindow.loginSubmitButton.click(); + // get values from Component + String caption = loginWindow.loginButton.getCaption() + boolean enabled = loginWindow.loginButton.is(ENABLED) + + Untyped loginFormLayout = wire(Untyped.class, "loginFormLayout") + loginFormLayout.shouldBe(VISIBLE) + + loginWindow.loginButton.click() + + close() + } } ```