Skip to content

Commit 4277bd4

Browse files
committed
Fix replay crash by catching if widget not found
1 parent e04f8e6 commit 4277bd4

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

testar/src/org/testar/monkey/ReplayMode.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.testar.monkey.alayer.Verdict;
5555
import org.testar.monkey.alayer.Widget;
5656
import org.testar.monkey.alayer.exceptions.ActionFailedException;
57+
import org.testar.monkey.alayer.exceptions.WidgetNotFoundException;
5758
import org.testar.serialisation.LogSerialiser;
5859

5960
public class ReplayMode {
@@ -177,11 +178,16 @@ public void runReplayLoop(DefaultProtocol protocol) {
177178
actionHasWidgetAssociated = true;
178179
Widget w;
179180
for (Finder f : targets){
180-
w = f.apply(state);
181-
if (w != null){
182-
//Can be this the widget the one that we want to find?
183-
if(widgetStringToFind.equals(w.get(Tags.Title, "")))
184-
widgetTitleFound = true;
181+
try {
182+
w = f.apply(state);
183+
if (w != null){
184+
//Can be this the widget the one that we want to find?
185+
if(widgetStringToFind.equals(w.get(Tags.Title, "")))
186+
widgetTitleFound = true;
187+
}
188+
} catch(WidgetNotFoundException e) {
189+
LogSerialiser.log("WidgetNotFoundException when trying to replay the widget: " + widgetStringToFind + "\n",
190+
LogSerialiser.LogLevel.Critical);
185191
}
186192
}
187193
}

0 commit comments

Comments
 (0)