这是我的测试班
/**
*
*/
package com.igate.test;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.igate.framework.BaseTestCase;
import com.igate.framework.ExecutionObject;
import com.igate.framework.GalenTestLayout;
import com.igate.framework.Reporter;
import com.igate.framework.WebDriver;
@Test
public class FleetBooking extends BaseTestCase {
public FleetBooking() {
super();
}
public ExecutionObject exeObj;
@BeforeClass
public void createDoc() throws Exception {
Reporter.createDoc(deviceDetail);
exeObj = new ExecutionObject();
}
public void test_case1() throws Exception {
WebDriver oWD = null;
if (runType.contains("mobile")) {
oWD = new WebDriver(ObjMap, caps, deviceDetail);
} else if (runType.contains("desktop")) {
oWD = new WebDriver(ObjMap, caps);
}
try {
oWD.startTestCase("test_casen1", exeObj);
oWD.launchURL("https://fleet.igate.com/fleet/Login.htm");
oWD.wait("MW");
oWD.setPage("LoginPage");
oWD.enterText("username", "831457");
RemoteWebDriver driver = oWD.getDriver();
System.out.println(" returned driver "+driver);
GalenTestLayout layout = new GalenTestLayout();
layout.testLayout(driver, "fleet");
//oWD.layoutTest("fleet");
/*try {
System.out.println("layout under process");
LayoutReport layoutReport = Galen.checkLayout(driver, "gspecs/fleet.gspec",
Arrays.asList("mobile","desktop"));
// Creating a list of tests
List<GalenTestInfo> tests = new LinkedList<GalenTestInfo>();
// Creating an object that will contain the information about the
// test
GalenTestInfo test = GalenTestInfo
.fromString("Login page on mobile device test");
// Adding layout report to the test report
test.getReport().layout(layoutReport,
"check layout on mobile device");
tests.add(test);
System.out.println("report created in reports folder");
// Exporting all test reports to html
new HtmlReportBuilder().build(tests,
"reports");
} catch (IOException e) {
System.out.println("error 1"+e.getMessage());
e.printStackTrace();
}*/
oWD.endTestCase();
} catch (Exception e) {
System.out.println("SYSOUT - exception : " + e);
oWD.endTestCase();
}
}
}
这是我的GalenTestLayout类
package com.igate.framework;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
import com.galenframework.api.Galen;
import com.galenframework.reports.GalenTestInfo;
import com.galenframework.reports.HtmlReportBuilder;
import com.galenframework.reports.model.LayoutReport;
import com.galenframework.testng.GalenTestNgTestBase;
public class GalenTestLayout {
public RemoteWebDriver driver;
@Test
public void testLayout(RemoteWebDriver driver,String gspec) {
System.out.println("driver in layout method "+driver);
LayoutReport layoutReport;
try {
System.out.println("layout under process");
layoutReport = Galen.checkLayout(driver, "gspecs/fleet.gspec",
Arrays.asList("mobile","desktop"));
// Creating a list of tests
List<GalenTestInfo> tests = new LinkedList<GalenTestInfo>();
// Creating an object that will contain the information about the
// test
GalenTestInfo test = GalenTestInfo
.fromString("Login page on mobile device test");
// Adding layout report to the test report
test.getReport().layout(layoutReport,
"check layout on mobile device");
tests.add(test);
System.out.println("report created in reports folder");
// Exporting all test reports to html
new HtmlReportBuilder().build(tests,
"reports");
} catch (IOException e) {
System.out.println("error in layout method "+e.getMessage());
e.printStackTrace();
}
}
}
我在我的 FleetBooking 课程中遇到错误
**GalenTestLayout layout = new GalenTestLayout();
layout.testLayout(driver, "fleet");**
这些是我的错误日志
[TestNG] Running:
C:\Users\pmadge\AppData\Local\Temp\testng-eclipse-1054887367\testng-customsuite.xml
bin compiled version 1.1
2016-04-26 20:14:08 INFO BaseTestCase:134 - Framework assigned in Internal Path : - Successfull
device size :3
*************taken device*********** 0
increasing count :1
looped i :0
Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 20891
Only local connections are allowed.
2016-04-26 20:14:10 INFO WebDriver:739 - StartTestCase - test_casen1 - Successfull
2016-04-26 20:14:10 INFO WebDriver:181 - Launch URL - : https://fleet.igate.com/fleet/Login.htm - Successfull
########$$$$$$$$$$%%%%%%%%%%%%%% ::::::::::::: null
2016-04-26 20:14:15 INFO WebDriver:155 - SetPage - : LoginPage - Successfull
2016-04-26 20:14:17 INFO WebDriver:610 - GetControl - Action Performed : username - Successfull
2016-04-26 20:14:17 INFO WebDriver:622 - FetchControl - Action Performed - Successfull
2016-04-26 20:14:19 INFO WebDriver:612 - GetControl - WebElement - Successfull
2016-04-26 20:14:19 INFO WebDriver:206 - enterText - in: username value: 831457 - Successfull
returned driver ChromeDriver: chrome on XP (92edabdf1bacb26c65c50ac893f7da3f)
driver in layout method ChromeDriver: chrome on XP (92edabdf1bacb26c65c50ac893f7da3f)
layout under process
FAILED: test_case1
java.lang.ExceptionInInitializerError
at com.galenframework.rainbow4j.Rainbow4J.loadImage(Rainbow4J.java:286)
at com.galenframework.utils.GalenUtils.takeScreenshot(GalenUtils.java:314)
at com.galenframework.browser.SeleniumBrowser.makeSimpleScreenshot(SeleniumBrowser.java:97)
at com.galenframework.browser.SeleniumBrowser.createScreenshot(SeleniumBrowser.java:90)
at com.galenframework.page.selenium.SeleniumPage.createScreenshot(SeleniumPage.java:161)
at com.galenframework.api.Galen.checkLayoutForPage(Galen.java:100)
at com.galenframework.api.Galen.checkLayout(Galen.java:86)
at com.galenframework.api.Galen.checkLayout(Galen.java:69)
at com.galenframework.api.Galen.checkLayout(Galen.java:59)
at com.galenframework.api.Galen.checkLayout(Galen.java:154)
at com.galenframework.api.Galen.checkLayout(Galen.java:128)
at com.igate.framework.GalenTestLayout.testLayout(GalenTestLayout.java:31)
at com.igate.test.FleetBooking.test_case1(FleetBooking.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.SecurityException: sealing violation: can't seal package com.sun.media.imageioimpl.plugins.jpeg2000: already loaded
at java.net.URLClassLoader.getAndVerifyPackage(Unknown Source)
at java.net.URLClassLoader.definePackageInternal(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.util.ServiceLoader$LazyIterator.nextService(Unknown Source)
at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
at java.util.ServiceLoader$1.next(Unknown Source)
at javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(Unknown Source)
at javax.imageio.spi.IIORegistry.<init>(Unknown Source)
at javax.imageio.spi.IIORegistry.getDefaultInstance(Unknown Source)
at javax.imageio.ImageIO.<clinit>(Unknown Source)
... 37 more
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.jq.Main@1ed3c8d: 21 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@2efe5d: 76 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 4 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@1f95c5d: 36 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@a570f: 4 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@81f4dc: 3 ms
正如您在我的输出日志中看到的那样,我的 chrome 驱动程序已正确初始化。
当我运行功能layout.testLayout(driver, "fleet"); 作为一个独立的类,它正在运行,但是当我从 testng 类调用这个方法时,我得到了异常。我尝试了很多替代方法,但它仍然给我错误