我正在尝试使用cucumber testng框架和galen测试来测试我网站上的ux组件。但是在执行时,我得到了error referenceerror:“org”没有定义
只有当我尝试使用cucumber testng框架运行测试时,才会出现这个问题。当我尝试只使用testng依赖项运行同一个test verifyuxcomponent()时,这个方法成功地执行了。
使用testng framework运行时出错:
ReferenceError: "org" is not defined. (<cmd>; line 1)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:597)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:557)
at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1076)
at org.mozilla.javascript.gen.c2.call(<cmd>:1)
at org.mozilla.javascript.gen.c2.exec(<cmd>)
at org.mozilla.javascript.Context.evaluateReader(Context.java:820)
at org.mozilla.javascript.Context.evaluateString(Context.java:784)
at com.galenframework.javascript.GalenJsExecutor.importClasses(GalenJsExecutor.java:85)
at com.galenframework.javascript.GalenJsExecutor.importAllMajorClasses(GalenJsExecutor.java:62)
at com.galenframework.javascript.GalenJsExecutor.<init>(GalenJsExecutor.java:58)
at com.galenframework.speclang2.pagespec.PageSpecHandler.createGalenJsExecutor(PageSpecHandler.java:97)
at com.galenframework.speclang2.pagespec.PageSpecHandler.<init>(PageSpecHandler.java:65)
at com.galenframework.speclang2.pagespec.PageSpecReader.read(PageSpecReader.java:59)
at com.galenframework.speclang2.pagespec.PageSpecReader.read(PageSpecReader.java:45)
at com.galenframework.api.Galen.checkLayout(Galen.java:68)
at com.galenframework.api.Galen.checkLayout(Galen.java:59)
at com.galenframework.api.Galen.checkLayout(Galen.java:155)
at com.galenframework.api.Galen.checkLayout(Galen.java:129)
maven依赖项
<!-- https://mvnrepository.com/artifact/com.galenframework/galen-java-support -->
<dependency>
<groupId>com.galenframework</groupId>
<artifactId>galen-java-support</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.6.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>6.6.0</version>
</dependency>
试验方法:
public void verifyUXComponent() throws IOException {
String specFile = "src/test/resources/specs/Test.gspec";
LayoutReport layoutReport = Galen.checkLayout(driver, specFile, Collections.singletonList("desktop"));
try {
List<GalenTestInfo> tests = new LinkedList<>();
//The object you create will be consisting the information regarding the test
GalenTestInfo test = GalenTestInfo.fromString("Test Automation Using Galen Framework");
//Adding layout report to the test report
test.getReport().layout(layoutReport, "Verify logo present and logo image comparison");
tests.add(test);
//Exporting all test report to html
new HtmlReportBuilder().build(tests, "target/galen-html-reports");
} catch (Exception e) {
e.printStackTrace();
}
}
暂无答案!
目前还没有任何答案,快来回答吧!