Skip to content

Commit

Permalink
fix: Handle no elementId (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
john7doe authored and dpgraham committed Jan 23, 2019
1 parent 1e908f8 commit cda2724
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -32,7 +34,10 @@ public class SetOrientation implements RequestHandler<OrientationParams, Void> {
@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"}).
Expand Down

0 comments on commit cda2724

Please sign in to comment.