// Click causes repaint, after this the old button element should no
// longer be available
// Ensure that the theme has changed
- waitUntil(new ExpectedCondition<Boolean>() {
- @Override
- public Boolean apply(WebDriver input) {
- WebElement app = input.findElement(By.className("v-app"));
- return hasCssClass(app, "runo");
- }
- });
+ waitForThemeToChange("runo");
try {
button.click();
Assert.fail("The old button element should have been removed by the click and replaced by a new one.");
@Test
public void testUpdatedTheme() {
- EmbeddedElement embedded = $(EmbeddedElement.class).first();
- final ImageElement image = $(ImageElement.class).first();
- final String initial = image.getAttribute("src");
+ final String initial = $(ImageElement.class).first()
+ .getAttribute("src");
// update theme
$(ButtonElement.class).first().click();
+ waitForThemeToChange("reindeer");
+
+ EmbeddedElement embedded = $(EmbeddedElement.class).first();
+ // Re fetch as theme change creates new elements
+ final ImageElement image = $(ImageElement.class).first();
waitUntil(new ExpectedCondition<Boolean>() {
@Override
embedded.findElement(By.tagName("img")).getAttribute("src"),
is(image.getAttribute("src")));
}
+
}
return (WebElement) executeScript("return document.activeElement;");
}
+
+ protected void waitForThemeToChange(final String theme) {
+
+ final WebElement rootDiv = findElement(By
+ .xpath("//div[contains(@class,'v-app')]"));
+ waitUntil(new ExpectedCondition<Boolean>() {
+
+ @Override
+ public Boolean apply(WebDriver input) {
+ String rootClass = rootDiv.getAttribute("class").trim();
+
+ return rootClass.contains(theme);
+ }
+ }, 30);
+ }
+
}
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.support.ui.ExpectedCondition;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.ComboBoxElement;
waitForThemeToChange(theme);
}
- private void waitForThemeToChange(final String theme) {
-
- final WebElement rootDiv = findElement(By
- .xpath("//div[contains(@class,'v-app')]"));
- waitUntil(new ExpectedCondition<Boolean>() {
-
- @Override
- public Boolean apply(WebDriver input) {
- String rootClass = rootDiv.getAttribute("class").trim();
-
- return rootClass.contains(theme);
- }
- }, 30);
- }
-
}
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.support.ui.ExpectedCondition;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.parallel.Browser;
private void changeTheme(final String theme) {
$(ButtonElement.class).caption(theme).first().click();
-
- final WebElement rootDiv = findElement(By
- .xpath("//div[contains(@class,'v-app')]"));
- waitUntil(new ExpectedCondition<Boolean>() {
-
- @Override
- public Boolean apply(WebDriver input) {
- String rootClass = rootDiv.getAttribute("class").trim();
-
- return rootClass.contains(theme);
- }
- }, 30);
+ waitForThemeToChange(theme);
}
private void assertFavicon(String theme) {
import org.junit.Test;
import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.support.ui.ExpectedCondition;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
}
}
- private void waitForThemeToChange(final String theme) {
-
- final WebElement rootDiv = findElement(By
- .xpath("//div[contains(@class,'v-app')]"));
- waitUntil(new ExpectedCondition<Boolean>() {
-
- @Override
- public Boolean apply(WebDriver input) {
- String rootClass = rootDiv.getAttribute("class").trim();
-
- return rootClass.contains(theme);
- }
- }, 30);
- }
-
private void assertOverlayTheme(String theme) {
final WebElement overlayContainerDiv = findElement(By
.xpath("//div[contains(@class,'v-overlay-container')]"));