From bbd713de6632cc86de8bb1da0b0e58faf3fbd731 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Tue, 14 Oct 2014 16:09:02 +0300 Subject: Add logging helper functions to AbstractTB3Test. Change-Id: Ie2f85c744eac7f8451f22c717a9aea5ea2e74f0e --- .../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 02913f59a1..108d72b91e 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -27,6 +27,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Field; import java.net.URL; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -66,6 +67,8 @@ import com.vaadin.testbench.TestBench; import com.vaadin.testbench.TestBenchDriverProxy; import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.TestBenchTestCase; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.VerticalLayoutElement; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.tb3.MultiBrowserTest.Browser; import com.vaadin.ui.UI; @@ -1256,6 +1259,30 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { return null; } + protected boolean logContainsText(String string) { + List logs = getLogs(); + + for (String text : logs) { + if (text.contains(string)) { + return true; + } + } + + return false; + } + + protected List getLogs() { + VerticalLayoutElement log = $(VerticalLayoutElement.class).id("Log"); + List logLabels = log.$(LabelElement.class).all(); + List logTexts = new ArrayList(); + + for (LabelElement label : logLabels) { + logTexts.add(label.getText()); + } + + return logTexts; + } + private static JSONObject extractObject(HttpResponse resp) throws IOException, JSONException { InputStream contents = resp.getEntity().getContent(); -- cgit v1.2.3