我的问题陈述与与基于Web的终端进行交互有关 通过硒
命令
curl -X POST https://dummyterminal/oauth/token -k -H
'authorization: Basic Authcode' -H 'content-type: application/x-www-
form-urlencoded' -d
'username=username&password=#password&grant_type=password'
我也尝试从Selenium IDE捕获整个流程,以便确定终端是否具有某些Web元素
对于终端,它将web元素显示为
cssSelector("canvas.xterm-cursor-layer")
通过Selenium IDE,但是当我使用相同的Web元素运行时,它已抛出错误以下
我也尝试过在Google上进行搜索,但是大多数解决方案都是腻子与Java代码的相关交互,这意味着台式机的交互 Java代码的腻子应用程序,但就我而言,我需要 与基于Web的终端(与腻子)和硒进行交互 这样我就可以在其中粘贴命令并检索输出
我无法将以上命令粘贴到基于Web的终端中, 出现以下错误:-
输出:-
org.openqa.selenium.WebDriverException: unknown error: cannot focus element
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 70 milliseconds
Build info: version: '2.53.0', revision: 'XXXX', time: '2016-03-15 16:57:40'
System info: host: 'XXXX', ip: 'XXXXXX', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.36.540470 (e522d04694cxxxx7e21272dbef4f9b818c91), userDataDir=C:\Users\XXXXX[enter image description here][1]\AppData\Local\Temp\scoped_dir3736_24657}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=70.0.3538.77, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=false, acceptInsecureCerts=false, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: f629216f0f8cvvvvvv6f7d95
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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 org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:122)
at getToken.getAccessToken.captureTerminalOutput(getAccessToken.java:52)
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:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
答案 0 :(得分:0)
对于终端,它将Web元素显示为cssSelector(“ canvas .xterm-cursor-layer”)。...
Selenium和任何其他基于DOM的工具都不能不能自动执行canvas元素内的操作。对于这些工具,canvas元素是一个大黑匣子,它们在内部看不到(xpath定位器不起作用)。
canvas test automation的一个好的解决方案是使用 Kantu Seleniium IDE并安装real-user simulation xmodule(开源,免费)。这为您提供了xclick
和xtype
命令,它们对于画布元素测试非常有用。 XClicks将图像作为输入,因此您可以使用图像来告诉XClick单击位置,而不是xpaths或CSS选择器。与Xtype相同,这是类似sendkeys的命令。