// creation
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PButton button1 = new PButton("A button");
button1.ensureDebugId("button1");
PRootPanel.get().add(button1);
register(button1);
}
});
WebElement element = findElementById("button1");
Assert.assertEquals("A button", element.getText());
// update text
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PButton button1 = get("button1");
button1.setText("New text of the button");
}
});
element = findElementById("button1");
Assert.assertEquals("New text of the button", element.getText());
// update html
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PButton button1 = get("button1");
button1.setHTML("Button <font color='red'>with pure html</font>");
}
});
element = findElementById("button1");
Assert.assertEquals("Button with pure html", element.getText());
final WebElement font = element.findElement(By.tagName("font"));
final String color = font.getAttribute("color");
Assert.assertEquals("red", color);
// check server fields
final PButton anchor = get("button1");
Assert.assertEquals("New text of the button", anchor.getText());
Assert.assertEquals("Button <font color='red'>with pure html</font>", anchor.getHTML());
}