Skip to content

Commit

Permalink
Add context switching funtionality
Browse files Browse the repository at this point in the history
  • Loading branch information
pavankovurru committed Sep 4, 2024
1 parent c9ac1ce commit 47da6c8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions documents/README_ANDROID.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

1. **Appium Inspector:**
[Appium Inspector GitHub Repository](https://github.com/appium/appium-inspector)
2.
[Locators Execution Time](https://github.com/appium/appium-uiautomator2-driver/blob/master/README.md#element-location)

```bash
# Have the app running, open `appium-inspector`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,25 @@ public void swipeVertical(
.perform();
}

//Context Switching
// Get all available contexts (Native and WebView)
public List<String> getAllContexts() {
@SuppressWarnings("unchecked")
List<String> contexts = (List<String>) driver.executeScript("mobile: getContexts");
log.info("Available contexts: " + contexts);
return contexts;
}

public void switchToContext(String context) {
log.info("Trying to switch to context - "+context);
driver.executeScript("mobile:Set Context");
}

public String getCurrentContext(String context) {
log.info("Trying to get current context");
return (String) driver.executeScript("Get Current Context");
}

// ******* ANDROID ONLY ******** //

//Android EXECUTE METHODS - https://github.com/appium/appium-uiautomator2-driver/blob/master/docs/android-mobile-gestures.md
Expand Down

0 comments on commit 47da6c8

Please sign in to comment.