From 2e6ca9573711f505330f0980531f5e44d4a252e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20S=C3=B8ndergaard?= Date: Tue, 22 Jan 2019 13:17:14 +0100 Subject: [PATCH] Handle no elementId --- .../appium/espressoserver/lib/handlers/SetOrientation.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetOrientation.java b/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetOrientation.java index 68985c273..85772bfa7 100644 --- a/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetOrientation.java +++ b/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetOrientation.java @@ -17,6 +17,8 @@ package io.appium.espressoserver.lib.handlers; import androidx.test.espresso.ViewInteraction; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; +import static androidx.test.espresso.Espresso.onView; import java.util.Arrays; @@ -32,7 +34,10 @@ public class SetOrientation implements RequestHandler { @Override @Nullable public Void handle(OrientationParams params) throws AppiumException { - final ViewInteraction viewInteraction = Element.getViewInteractionById(params.getElementId()); + final String elementId = params.getElementId(); + final ViewInteraction viewInteraction = elementId == null + ? onView(isRoot()) + : Element.getViewInteractionById(elementId); final String orientation = params.getOrientation(); if (orientation == null || !Arrays.asList(new String[] {"LANDSCAPE", "PORTRAIT"}).