2
私はページの "読み込み時間"をテストするために、次のスクリプトで "eyes.testResponseTime(ドライバ、アプリケーション名、テスト名、アクション、期限、タイムアウト、ビューポートサイズ);"と上記のエラーが発生しました。メソッドは "Applitools"(Visual Validationで使用されています)のメソッドです。これを手伝って、この方法を効果的に使う方法を私に教えてください。私には簡単な作業コードを教えてください。事前のおかげで...java.lang.NoSuchMethodError:javax.ws.rs.core.MultivaluedMap.addAll(Ljava/lang/Object; [Ljava/lang/Object;)
コード:
import java.net.URI;
import java.net.URISyntaxException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import com.applitools.eyes.Eyes;
import com.applitools.eyes.StdoutLogHandler;
public class LoadTime {
public static void main(String[] args) {
Eyes eyes =null;
WebDriver driver =null;
try {
driver = new FirefoxDriver();
eyes = new Eyes(new URI("https://applitools.com"));
eyes.setApiKey("Type_Applitools_Key_Here");
eyes.setLogHandler(new StdoutLogHandler(true));
// Load the applitools login page.
driver.get("https://applitools.com/login/");
// Enter the username and password. But don't click on "Login" just yet.
driver.findElement(By.id("user_login")).sendKeys("Enter User Name");
driver.findElement(By.id("user_pass")).sendKeys("Enter Password");
Thread.sleep(4000);
try {
eyes.testResponseTime(driver, "Applitools Website", "Login performance test 1",
// We want time to be measured from when we click on the
// "Login" button.
new Eyes.WebDriverAction() {
public void drive(WebDriver driver) {
driver.findElement(By.id("wp-submit")).click();
}
}, 20,new RectangleSize(1024, 600));
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} finally {
eyes.abortIfNotClosed();
driver.quit();
}
}
}
エラーがメソッドで発生します。 eyes.testResponseTime()上記のコードを参照してください。
のpom.xml:
<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>
<groupId> T_TestSuite</groupId>
<artifactId>T_TestSuite</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name></name>
<description>AutomateT</description>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.7</jdk.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<compilerArgument></compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<systemPropertyVariables>
<buildnumber>${build.number}</buildnumber>
<jobname>${job.name}</jobname>
</systemPropertyVariables>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter,com.automateon.TestProgressListener</value>
</property>
</properties>
<reportsDirectory>${project.basedir}/target/</reportsDirectory>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<build.number>${BUILD_NUMBER}</build.number>
<job.name>${JOB_NAME}</job.name>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>LATEST</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.3</version>
<type>jar</type>
<classifier>jdk15</classifier>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
<type>jar</type>
<scope>compile</scope>
<optional>false</optional>
</dependency>
<dependency>
<groupId>RealTimeReports</groupId>
<artifactId>RealTimeReports</artifactId>
<version>1.0</version>
<classifier>jar-with-dependencies</classifier>
<scope>system</scope>
<systemPath>${project.basedir}/lib/RealTimeReports.jar</systemPath>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.applitools</groupId>
<artifactId>eyes-selenium-java</artifactId>
<version>2.32</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.22.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.8.7</version>
</dependency>
</dependencies>
</project>
コンソールログ:使用
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2016-05-03T16:12:17Z Eyes: openBase():Agent = eyes.selenium.java/2.31
2016-05-03T16:12:17Z Eyes: openBase():openBase('AppTest', 'Login Test', 'null')
2016-05-03T16:12:17Z Eyes: openBase():Eyes server URL is 'https://applitools.com'
2016-05-03T16:12:17Z Eyes: openBase():Timeout = '300000'
2016-05-03T16:12:17Z Eyes: openBase():matchTimeout = '2'
2016-05-03T16:12:17Z Eyes: openBase():Default match settings = 'Match level: STRICT, Exact match settings: null'
2016-05-03T16:12:17Z Eyes: openBase():FailureReports = 'ON_CLOSE'
2016-05-03T16:12:17Z Eyes: <init>():Driver session is 7XXXXXXXXXXXXXXXXXXXXX2
2016-05-03T16:12:17Z Eyes: testResponseTimeBase():testResponseTimeBase(regionProvider, 10, 30, 5000)
2016-05-03T16:12:17Z Eyes: testResponseTimeBase():No running session, calling start session..
2016-05-03T16:12:17Z Eyes: startSession():startSession()
2016-05-03T16:12:17Z Eyes: getDefaultContentViewportSize():getDefaultContentViewportSize()
2016-05-03T16:12:17Z Eyes: <init>():Frame chain copy constructor (size 0)
2016-05-03T16:12:17Z Eyes: <init>():Done!
2016-05-03T16:12:17Z Eyes: getDefaultContentViewportSize():Extracting viewport size...
2016-05-03T16:12:17Z Eyes: extractViewportSize():extractViewportSize()
2016-05-03T16:12:17Z Eyes: executeScript():Execute script...
2016-05-03T16:12:17Z Eyes: executeScript():Done!
2016-05-03T16:12:17Z Eyes: getDefaultContentViewportSize():Done! Viewport size: 1010x452
2016-05-03T16:12:17Z Eyes: startSession():No batch set
2016-05-03T16:12:17Z Eyes: getUserAgent():user agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
2016-05-03T16:12:17Z Eyes: getAppEnvironment():No OS set, checking for mobile OS...
2016-05-03T16:12:17Z Eyes: getAppEnvironment():No mobile OS detected.
2016-05-03T16:12:17Z Eyes: getAppEnvironment():Done!
2016-05-03T16:12:17Z Eyes: startSession():Application environment is [os = ? hostingApp = ? displaySize = 1010x452]
2016-05-03T16:12:17Z Eyes: startSession():Starting server session...
2016-05-03T16:12:17Z Eyes: abortIfNotClosed():Closed
Exception in thread "main" java.lang.NoSuchMethodError: javax.ws.rs.core.MultivaluedMap.addAll(Ljava/lang/Object;[Ljava/lang/Object;)V
at org.glassfish.jersey.client.ClientRequest.accept(ClientRequest.java:336)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:221)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:59)
at com.applitools.eyes.Jersey2xServerConnector.startSession(Jersey2xServerConnector.java:145)
at com.applitools.eyes.EyesBase.startSession(EyesBase.java:1348)
at com.applitools.eyes.EyesBase.testResponseTimeBase(EyesBase.java:1017)
at com.applitools.eyes.Eyes.testResponseTime(Eyes.java:452)
at com.applitools.eyes.Eyes.testResponseTime(Eyes.java:532)
at com.TL.Test.TDB.LoadTime.main(LoadTime.java:49)
参考文献:
1. http://support.applitools.com/customer/en/portal/articles/2167207-testing-your-page-s-loading-time?t=372225
2. https://eyes.applitools.com/app/tutorial.html