This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#174 Support for Applitools Eyes added
- Loading branch information
1 parent
933eef5
commit ce23e2e
Showing
5 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>bobcat</artifactId> | ||
<groupId>com.cognifide.qa.bb</groupId> | ||
<version>1.4.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>bb-eyes</artifactId> | ||
<name>Bobcat Eyes</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
</dependency> | ||
<!-- logging --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.applitools</groupId> | ||
<artifactId>eyes-selenium-java3</artifactId> | ||
<version>RELEASE</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>io.appium</groupId> | ||
<artifactId>java-client</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.cognifide.qa.bb</groupId> | ||
<artifactId>bb-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.rat</groupId> | ||
<artifactId>apache-rat-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
31 changes: 31 additions & 0 deletions
31
bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/EyesModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*- | ||
* #%L | ||
* Bobcat | ||
* %% | ||
* Copyright (C) 2016 Cognifide Ltd. | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
package com.cognifide.qa.bb.eyes; | ||
|
||
import com.applitools.eyes.selenium.Eyes; | ||
import com.google.inject.AbstractModule; | ||
|
||
public class EyesModule extends AbstractModule { | ||
|
||
@Override | ||
protected void configure() { | ||
bind(Eyes.class).toProvider(EyesProvider.class); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/EyesProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.cognifide.qa.bb.eyes; | ||
|
||
import com.applitools.eyes.selenium.Eyes; | ||
import com.cognifide.qa.bb.guice.ThreadScoped; | ||
import com.google.inject.Inject; | ||
import com.google.inject.Provider; | ||
import com.google.inject.name.Named; | ||
|
||
@ThreadScoped | ||
public class EyesProvider implements Provider<Eyes> { | ||
|
||
private Eyes cachedEyes; | ||
|
||
@Inject | ||
@Named("eyes.apiKey") | ||
private String apiKey; | ||
|
||
@Inject | ||
@Named("eyes.fullPageScreenshots") | ||
private boolean fullPageScreenshots; | ||
|
||
@Override | ||
public Eyes get() { | ||
if (cachedEyes == null) { | ||
cachedEyes = create(); | ||
} | ||
return cachedEyes; | ||
} | ||
|
||
private Eyes create() { | ||
Eyes eyes = new Eyes(); | ||
eyes.setApiKey(apiKey); | ||
eyes.setForceFullPageScreenshot(fullPageScreenshots); | ||
return eyes; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
bb-eyes/src/main/java/com/cognifide/qa/bb/eyes/WithEyes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.cognifide.qa.bb.eyes; | ||
|
||
import org.junit.rules.TestRule; | ||
import org.junit.runner.Description; | ||
import org.junit.runners.model.Statement; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.events.EventFiringWebDriver; | ||
|
||
import com.applitools.eyes.selenium.Eyes; | ||
import com.google.inject.Inject; | ||
import com.google.inject.name.Named; | ||
|
||
public class WithEyes implements TestRule { | ||
|
||
private final WebDriver webDriver; | ||
private final Eyes eyes; | ||
private String appName; | ||
|
||
@Inject | ||
public WithEyes(WebDriver webDriver, Eyes eyes, @Named("eyes.appName") String appName) { | ||
this.webDriver = webDriver; | ||
this.eyes = eyes; | ||
this.appName = appName; | ||
} | ||
|
||
public WebDriver getWebDriver() { | ||
return webDriver; | ||
} | ||
|
||
public Eyes getEyes() { | ||
return eyes; | ||
} | ||
|
||
@Override | ||
public Statement apply(Statement base, Description description) { | ||
return new Statement() { | ||
@Override | ||
public void evaluate() throws Throwable { | ||
try { | ||
WebDriver wrappedDriver = ((EventFiringWebDriver) webDriver).getWrappedDriver(); | ||
eyes.open(wrappedDriver, appName, description.getMethodName()); | ||
base.evaluate(); | ||
} finally { | ||
closeEyes(); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
private void closeEyes() { | ||
try { | ||
eyes.close(); | ||
} finally { | ||
eyes.abortIfNotClosed(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
default: | ||
properties: | ||
eyes.apiKey: '' | ||
eyes.fullPageScreenshots: true | ||
eyes.appName: '' |