如何解决警告:Eclipse中org.testng.xml.XMLParser的非法反射访问?

时间:2019-04-13 03:14:58

标签: java eclipse testng

我正在尝试使用appium服务器在eclipse中运行appium studio代码。代码包含“ TestNG ”框架,但收到非法反射访问org.testng.xml.XMLParser的错误。怎么了?

以下提到错误。 测试字段包含要在我的真实设备上运行的步骤。

    WARNING: Illegal reflective access by org.testng.xml.XMLParser (file:/C:/Users/admin/.gradle/caches/modules-2/files-2.1/org.testng/testng/6.9.10/6feb3e964aeb7097aff30c372aac3ec0f8d87ede/testng-6.9.10.jar) to constructor com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl()
[TestNG] Running:
  C:\Users\admin\AppData\Local\Temp\testng-eclipse--1915666960\testng-customsuite.xml

Apr 12, 2019 3:08:34 PM org.openqa.selenium.remote.RemoteWebDriver log
INFO: Executing: findElement [9f67725e-e265-4adf-b9fa-603db96a638e, findElement {using=xpath, value=(//*[@id='listAllImgByCat']/*/*/*/*[@id='icPlayVideo'])[1]}]
Apr 12, 2019 3:08:34 PM org.openqa.selenium.remote.RemoteWebDriver log
INFO: Executed: [9f67725e-e265-4adf-b9fa-603db96a638e, findElement {using=xpath, value=(//*[@id='listAllImgByCat']/*/*/*/*[@id='icPlayVideo'])[1]}]
Apr 12, 2019 3:08:34 PM org.openqa.selenium.remote.RemoteWebDriver log
INFO: Executing: quit [9f67725e-e265-4adf-b9fa-603db96a638e, quit {}]
Apr 12, 2019 3:08:39 PM org.openqa.selenium.remote.RemoteWebDriver log
INFO: Executed: [9f67725e-e265-4adf-b9fa-603db96a638e, quit {}]
FAILED: testAndroidDemoTest
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 206 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'admin-PC', ip: '192.168.0.145', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '12'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{appPackage=com.gifmaker.videobanner.animated, deviceScreenSize=1536x2048, networkConnectionEnabled=true, warnings={}, reportFormat=xml, databaseEnabled=false, deviceName=43AF6007, platform=LINUX, deviceUDID=43AF6007, appActivity=com.ui.activity.SplashActivity, desired={appPackage=com.gifmaker.videobanner.animated, appActivity=com.ui.activity.SplashActivity, reportDirectory=reports, reportFormat=xml, udid=43AF6007, platformName=Android, deviceName=Nokia, testName=AndroidDemoTest}, platformVersion=4.4.4, webStorageEnabled=false, locationContextEnabled=false, takesScreenshot=true, reportDirectory=reports, javascriptEnabled=true, deviceModel=MI PAD, udid=43AF6007, platformName=Android, deviceManufacturer=Xiaomi, testName=AndroidDemoTest}]
Session ID: 9f67725e-e265-4adf-b9fa-603db96a638e
*** Element info: {Using=xpath, value=(//*[@id='listAllImgByCat']/*/*/*/*[@id='icPlayVideo'])[1]}
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
    at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:56)
    at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:500)
    at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:134)
    at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.findElementByXPath(AndroidDriver.java:1)
    at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)
    at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:52)
    at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
    at com.experitest.auto.AndroidDemoTest.testAndroidDemoTest(AndroidDemoTest.java:40)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
    at org.testng.TestRunner.privateRun(TestRunner.java:782)
    at org.testng.TestRunner.run(TestRunner.java:632)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
    at org.testng.SuiteRunner.run(SuiteRunner.java:268)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    at org.testng.TestNG.run(TestNG.java:1064)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)


===============================================
    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.XMLReporter@4148db48: 13 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@679b62af: 59 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@b59d31: 13 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@76a4d6c: 46 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 7 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@31206beb: 10 ms

1 个答案:

答案 0 :(得分:0)

您的TestNG版本很旧。最新版本(我正在使用6.14.3)没有表现出这种行为。该问题在TestNG问题跟踪器(https://github.com/cbeust/testng/issues/2076)上被标记为已关闭。