Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
natfirst committed May 15, 2018
1 parent dffe159 commit 938ba76
Showing 1 changed file with 54 additions and 26 deletions.
80 changes: 54 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<LoginWindow> {
@Wire
public TextField loginField;
Expand Down Expand Up @@ -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()
}
}
```

Expand Down

0 comments on commit 938ba76

Please sign in to comment.