use of com.vaadin.flow.component.button.testbench.ButtonElement in project flow by vaadin.
the class UIAccessContextIT method securityContextSetForUIAccess.
@Test
public void securityContextSetForUIAccess() throws Exception {
String expectedUserBalance = "Hello John the User, your bank account balance is $10000.00.";
String expectedAdminBalance = "Hello Emma the Admin, your bank account balance is $200000.00.";
WebDriver adminBrowser = getDriver();
try {
super.setup();
open("private");
loginUser();
TestBenchElement balance = $("span").id("balanceText");
Assert.assertEquals(expectedUserBalance, balance.getText());
open("private", adminBrowser);
HasElementQuery adminContext = new HasElementQuery() {
@Override
public SearchContext getContext() {
return adminBrowser;
}
};
loginAdmin(adminContext);
TestBenchElement adminBalance = adminContext.$("span").id("balanceText");
Assert.assertEquals(expectedAdminBalance, adminBalance.getText());
ButtonElement sendRefresh = $(ButtonElement.class).id("sendRefresh");
sendRefresh.click();
Assert.assertEquals(expectedUserBalance, balance.getText());
Assert.assertEquals(expectedAdminBalance, adminBalance.getText());
ButtonElement adminSendRefresh = adminContext.$(ButtonElement.class).id("sendRefresh");
adminSendRefresh.click();
Assert.assertEquals(expectedUserBalance, balance.getText());
Assert.assertEquals(expectedAdminBalance, adminBalance.getText());
} finally {
adminBrowser.quit();
}
}
Aggregations