Java.lang.LinkageError RFT - 硒 - Appium
Java.lang.LinkageError RFT - Selenium - Appium
我被困在这种情况下,我查阅了很多文档但找不到解决方案,我正在从事一个自动化 Web 和移动应用程序的项目,有时两者同时进行,因为有必须在它们之间传输的信息。
当 IDE (RFT) 本身 运行 时,自动化工作正常,但如果我尝试从 运行控制台它抛出以下错误。
exception_name = java.lang.LinkageError
exception_message = loading constraint violation when overriding method "org/openqa/selenium/remote/RemoteWebElement.findElement(Lorg/openqa/selenium/By;)Lorg/openqa/selenium/WebElement;" during creation of class "io/appium/java_client/DefaultGenericMobileElement": loader "com/rational/test/ft/util/FtClassLoader@c6ae7474" of class "io/appium/java_client/DefaultGenericMobileElement" and loader "com/rational/test/ft/util/FtClassLoader@a4fe6ba3" of class "org/openqa/selenium/remote/RemoteWebElement" have different types for the method signature
script_name = Platforms.Test.Test
script_id = Platforms.Test.Test.java
line_number = 40
exception_stack = at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:379)
at com.rational.test.ft.util.FtClassLoader.loadClass(FtClassLoader.java:159)
at java.lang.ClassLoader.loadClass(ClassLoader.java:854)
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:379)
at com.rational.test.ft.util.FtClassLoader.loadClass(FtClassLoader.java:159)
at java.lang.ClassLoader.loadClass(ClassLoader.java:854)
at com.rational.test.ft.util.FtClassLoader.callRelatedClassLoaders(FtClassLoader.java:356)
at com.rational.test.ft.util.FtClassLoader.loadClass(FtClassLoader.java:163)
at java.lang.ClassLoader.loadClass(ClassLoader.java:854)
at Platforms.Test.Test.testMain(Test.java:40)
at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
at org.eclipse.core.launcher.Main.main(Main.java:34)
这就是我从命令行 运行 自动化的方式,kernel.jar 是一组包含 Ant 的库,其中包含 java-client-7.3.0 ( io.appium.java_client), selenium.jar 是 selenium-server-standalone-3.141.59 (org.openqa.selenium):
"C:\Program Files\IBM\SDP\jdk\bin\java" -classpath "C:\Program Files\IBM\SDP\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -datastore "C:\Workspaces\RFT\Project" -projectpath "C:\Workspaces\RFT\Project\libs\inuse\kernel.jar;C:\Workspaces\RFT\Project\libs\inuse\selenium.jar" -log "Project.Test.Test" -playback "Platforms.Test.Test" -args "Test"
自动化脚本非常简单,它导入一个 类,其中包含使用 selenium 连接到 Web 门户、检索安全代码然后使用 appium 使用该代码在应用程序中进行身份验证的功能并执行其他操作,如果我从 IDE 本身 运行 重复一切正常。
public class Test extends TestHelper
{
/**
*
* @since 2020/08/21
* @author jddeltoro
*/
public void testMain(Object[] args)
{
Framework fw = Framework.getInstance();
try {
fw.initEnviromentTokens();
WebAppAutomation waa= new WebAppAutomation(fw);
waa.init();
String code = wpa.reatriveSecurityCode();
waa.quit();
MobileAppAutomation maa= new MobileAppAutomation(fw);
maa.init();
maa.executeProcess(code);
maa.quit();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
另一个重要的线索是,如果我 运行 来自命令行的脚本仅实例化 Selenium 或仅实例化 Appium,则 java.lang.LinkageError 不会显示, 这表明命令是正确的。
通过控制台执行的原因是我在远程执行,有数千个脚本,当一个完成后我开始执行另一个。
注意:
如果我使用已安装的 java 虚拟机,异常情况类似:
"java -classpath "C:\Program Files\IBM\SDP\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -datastore "C:\Workspaces\RFT\Project" -projectpath "C:\Workspaces\RFT\Project\libs\inuse\kernel.jar;C:\Workspaces\RFT\Project\libs\inuse\selenium.jar" -log "Project.Test.Test" -playback "Platforms.Test.Test" -args "Test"
exception_name = java.lang.LinkageError
exception_message = loader constraint violation: when resolving overridden method "io.appium.java_client.DefaultGenericMobileDriver.findElementById(Ljava/lang/String;)Lorg/openqa/selenium/WebElement;" the class loader (instance of com/rational/test/ft/util/FtClassLoader) of the current class, io/appium/java_client/DefaultGenericMobileDriver, and its superclass loader (instance of com/rational/test/ft/util/FtClassLoader), have different Class objects for the type org/openqa/selenium/WebElement used in the signature
我终于使用不同的触发命令解决了这个问题:
"C:\Program Files\IBM\SDP\jdk\bin\javaw.exe" -Dfile.encoding=Cp1252 -classpath "C:\Workspaces\RFT\Project\libs\inuse\kernel.jar;C:\Workspaces\RFT\Project\libs\inuse\selenium.jar;C:\Program Files\IBM\SDP\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -projectpath C:\Workspaces\RFT\Project -datastore C:\Workspaces\RFT\Project -idetype wswplugin -rt.interactive true -rt.log_format html -log Platforms.Test.Test -iterationcount ALL -rt.log_action false -rt.log_screen_snapshot false -playback Platforms.Test.Test
我被困在这种情况下,我查阅了很多文档但找不到解决方案,我正在从事一个自动化 Web 和移动应用程序的项目,有时两者同时进行,因为有必须在它们之间传输的信息。
当 IDE (RFT) 本身 运行 时,自动化工作正常,但如果我尝试从 运行控制台它抛出以下错误。
exception_name = java.lang.LinkageError
exception_message = loading constraint violation when overriding method "org/openqa/selenium/remote/RemoteWebElement.findElement(Lorg/openqa/selenium/By;)Lorg/openqa/selenium/WebElement;" during creation of class "io/appium/java_client/DefaultGenericMobileElement": loader "com/rational/test/ft/util/FtClassLoader@c6ae7474" of class "io/appium/java_client/DefaultGenericMobileElement" and loader "com/rational/test/ft/util/FtClassLoader@a4fe6ba3" of class "org/openqa/selenium/remote/RemoteWebElement" have different types for the method signature
script_name = Platforms.Test.Test
script_id = Platforms.Test.Test.java
line_number = 40
exception_stack = at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:379)
at com.rational.test.ft.util.FtClassLoader.loadClass(FtClassLoader.java:159)
at java.lang.ClassLoader.loadClass(ClassLoader.java:854)
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:379)
at com.rational.test.ft.util.FtClassLoader.loadClass(FtClassLoader.java:159)
at java.lang.ClassLoader.loadClass(ClassLoader.java:854)
at com.rational.test.ft.util.FtClassLoader.callRelatedClassLoaders(FtClassLoader.java:356)
at com.rational.test.ft.util.FtClassLoader.loadClass(FtClassLoader.java:163)
at java.lang.ClassLoader.loadClass(ClassLoader.java:854)
at Platforms.Test.Test.testMain(Test.java:40)
at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
at org.eclipse.core.launcher.Main.main(Main.java:34)
这就是我从命令行 运行 自动化的方式,kernel.jar 是一组包含 Ant 的库,其中包含 java-client-7.3.0 ( io.appium.java_client), selenium.jar 是 selenium-server-standalone-3.141.59 (org.openqa.selenium):
"C:\Program Files\IBM\SDP\jdk\bin\java" -classpath "C:\Program Files\IBM\SDP\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -datastore "C:\Workspaces\RFT\Project" -projectpath "C:\Workspaces\RFT\Project\libs\inuse\kernel.jar;C:\Workspaces\RFT\Project\libs\inuse\selenium.jar" -log "Project.Test.Test" -playback "Platforms.Test.Test" -args "Test"
自动化脚本非常简单,它导入一个 类,其中包含使用 selenium 连接到 Web 门户、检索安全代码然后使用 appium 使用该代码在应用程序中进行身份验证的功能并执行其他操作,如果我从 IDE 本身 运行 重复一切正常。
public class Test extends TestHelper
{
/**
*
* @since 2020/08/21
* @author jddeltoro
*/
public void testMain(Object[] args)
{
Framework fw = Framework.getInstance();
try {
fw.initEnviromentTokens();
WebAppAutomation waa= new WebAppAutomation(fw);
waa.init();
String code = wpa.reatriveSecurityCode();
waa.quit();
MobileAppAutomation maa= new MobileAppAutomation(fw);
maa.init();
maa.executeProcess(code);
maa.quit();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
另一个重要的线索是,如果我 运行 来自命令行的脚本仅实例化 Selenium 或仅实例化 Appium,则 java.lang.LinkageError 不会显示, 这表明命令是正确的。 通过控制台执行的原因是我在远程执行,有数千个脚本,当一个完成后我开始执行另一个。
注意: 如果我使用已安装的 java 虚拟机,异常情况类似:
"java -classpath "C:\Program Files\IBM\SDP\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -datastore "C:\Workspaces\RFT\Project" -projectpath "C:\Workspaces\RFT\Project\libs\inuse\kernel.jar;C:\Workspaces\RFT\Project\libs\inuse\selenium.jar" -log "Project.Test.Test" -playback "Platforms.Test.Test" -args "Test"
exception_name = java.lang.LinkageError
exception_message = loader constraint violation: when resolving overridden method "io.appium.java_client.DefaultGenericMobileDriver.findElementById(Ljava/lang/String;)Lorg/openqa/selenium/WebElement;" the class loader (instance of com/rational/test/ft/util/FtClassLoader) of the current class, io/appium/java_client/DefaultGenericMobileDriver, and its superclass loader (instance of com/rational/test/ft/util/FtClassLoader), have different Class objects for the type org/openqa/selenium/WebElement used in the signature
我终于使用不同的触发命令解决了这个问题:
"C:\Program Files\IBM\SDP\jdk\bin\javaw.exe" -Dfile.encoding=Cp1252 -classpath "C:\Workspaces\RFT\Project\libs\inuse\kernel.jar;C:\Workspaces\RFT\Project\libs\inuse\selenium.jar;C:\Program Files\IBM\SDP\FunctionalTester\bin\rational_ft.jar" com.rational.test.ft.rational_ft -projectpath C:\Workspaces\RFT\Project -datastore C:\Workspaces\RFT\Project -idetype wswplugin -rt.interactive true -rt.log_format html -log Platforms.Test.Test -iterationcount ALL -rt.log_action false -rt.log_screen_snapshot false -playback Platforms.Test.Test