Skip to content

Commit

Permalink
Update Java readme and versions for POA (#115)
Browse files Browse the repository at this point in the history
* Update Java readme and versions for POA

* Lint fix

* Fixing few issues
  • Loading branch information
Amit3200 authored Aug 10, 2023
1 parent 604aeb3 commit fbe5fde
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,65 @@ If you have a previous Percy configuration file, migrate it to the newest versio
```sh-session
$ percy config:migrate
```
## Running Percy on Automate
`percyScreenshot(driver, name, options)` [ needs @percy/cli 1.27.0-beta.0+ ];

This is an example test using the `percy.Screenshot` method.

``` java
// import ...
import io.percy.appium.PercyOnAutomate;

public class Example {

public static void main(String[] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities caps = new DesiredCapabilities();
// Add caps here

WebDriver driver = new RemoteWebDriver(new URL(URL), caps);

PercyOnAutomate percy = new PercyOnAutomate(driver);
percy.screenshot("First Screenshot");
driver.quit();
}
}
```

- `driver` (**required**) - A appium driver instance
- `name` (**required**) - The screenshot name; must be unique to each screenshot
- `options` (**optional**) - There are various options supported by percy_screenshot to server further functionality.
- `freezeAnimation` - Boolean value by default it falls back to `false`, you can pass `true` and percy will freeze image based animations.
- `percyCSS` - Custom CSS to be added to DOM before the screenshot being taken. Note: This gets removed once the screenshot is taken.
- `ignoreRegionXpaths` - elements in the DOM can be ignored using xpath
- `ignoreRegionSelectors` - elements in the DOM can be ignored using selectors.
- `ignoreRegionAppiumElements` - elements can be ignored using appium_elements.
- `customIgnoreRegions` - elements can be ignored using custom boundaries
- IgnoreRegion:-
- Description: This class represents a rectangular area on a screen that needs to be ignored for visual diff.

- Constructor:
```
init(self, top, bottom, left, right)
```
- Parameters:
`top` (int): Top coordinate of the ignore region.
`bottom` (int): Bottom coordinate of the ignore region.
`left` (int): Left coordinate of the ignore region.
`right` (int): Right coordinate of the ignore region.
- Raises:ValueError: If top, bottom, left, or right is less than 0 or top is greater than or equal to bottom or left is greater than or equal to right.
- valid: Ignore region should be within the boundaries of the screen.
### Creating Percy on automate build
Note: Automate Percy Token starts with `auto` keyword. The command can be triggered using `exec` keyword.
```sh-session
$ export PERCY_TOKEN=[your-project-token]
$ percy exec -- [python test command]
[percy] Percy has started!
[percy] [Python example] : Starting automate screenshot ...
[percy] Screenshot taken "Python example"
[percy] Stopping percy...
[percy] Finalized build #1: https://percy.io/[your-project]
[percy] Done!
```

Refer to docs here: [Percy on Automate](https://docs.percy.io/docs/integrate-functional-testing-with-visual-testing)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"devDependencies": {
"@percy/cli": "^1.26.2"
"@percy/cli": "^1.27.0-beta.1"
}
}
9 changes: 6 additions & 3 deletions src/main/java/io/percy/appium/lib/CliWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean healthcheck() {
JSONObject buildJsonObject = (JSONObject) myObject.get("build");
Environment.setPercyBuildID((String) buildJsonObject.get("id"));
Environment.setPercyBuildUrl((String) buildJsonObject.get("url"));
Environment.setSessionType((String) myObject.get("type"));
Environment.setSessionType((String) myObject.optString("type", null));

if (statusCode != 200) {
throw new RuntimeException("Failed with HTTP error code : " + statusCode);
Expand All @@ -61,9 +61,12 @@ public boolean healthcheck() {
AppPercy.log("Unsupported Percy CLI version, " + version);
return false;
} else {
if (minorVersion < 25) {
if (minorVersion < 27) {
AppPercy.log("Percy CLI version, " + version
+ " is not the minimum version required, some features might not work as expected.", "warn");
+ " is not minimum version required "
+ "Percy on Automate is available from 1.27.0-beta.0.",
"warn");
return false;
}
}

Expand Down

0 comments on commit fbe5fde

Please sign in to comment.