Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle no elementId #383

Merged
merged 1 commit into from
Jan 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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