Skip to content

Commit

Permalink
Added methods in driver class to set and retrieve clipboard text (#870)
Browse files Browse the repository at this point in the history
Co-authored-by: Snehith Tammewar <[email protected]>
  • Loading branch information
snehith07 and Snehith Tammewar authored Oct 25, 2024
1 parent 683a7da commit 9cc0e2b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/com/znsio/teswiz/runner/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -793,4 +793,22 @@ public boolean isElementDisplayed(By locator) {
List<WebElement> elementList = driver.findElements(locator);
return !elementList.isEmpty() && elementList.get(0).isDisplayed();
}

public String getClipboardText() {
return switch (Runner.getPlatform()) {
case android -> ((AndroidDriver) driver).getClipboardText();
case iOS -> ((IOSDriver) driver).getClipboardText();
default ->
throw new NotImplementedException("getClipboardText method is not implemented for " + Runner.getPlatform());
};
}

public void setClipboardText(String text) {
switch (Runner.getPlatform()) {
case android -> ((AndroidDriver) driver).setClipboardText(text);
case iOS -> ((IOSDriver) driver).setClipboardText(text);
default ->
throw new NotImplementedException("setClipboardText method is not implemented for " + Runner.getPlatform());
}
}
}

0 comments on commit 9cc0e2b

Please sign in to comment.