Selenium webdriver 如何通过OKTA执行相同的脚本

Selenium webdriver 如何通过OKTA执行相同的脚本,selenium-webdriver,Selenium Webdriver,我必须为不同的客户机运行相同的脚本,在这些客户机中,我需要对脚本进行一些更改 并且对于每个客户端都运行良好。对于每个客户端,我们都有不同的URL,一个用于测试,另一个用于生产环境 最近我的公司推出了OKTA,一个URL必须通过有效凭证登录,在主页上会找到 每个客户端的图标(图像)(例如,客户端ABC的ABCTest和ABCProd图标)。一旦点击所需的图标,它会直接带你去 特定应用程序的主页。 我成功地使用主URL登录,点击打开主页的特定图标,但第一次登录失败。 我已经使用POM设计和TestN

我必须为不同的客户机运行相同的脚本,在这些客户机中,我需要对脚本进行一些更改 并且对于每个客户端都运行良好。对于每个客户端,我们都有不同的URL,一个用于测试,另一个用于生产环境 最近我的公司推出了OKTA,一个URL必须通过有效凭证登录,在主页上会找到 每个客户端的图标(图像)(例如,客户端ABC的ABCTest和ABCProd图标)。一旦点击所需的图标,它会直接带你去 特定应用程序的主页。 我成功地使用主URL登录,点击打开主页的特定图标,但第一次登录失败。 我已经使用POM设计和TestNG与maven项目创建了混合框架。 它应该执行以下方法来打开一个特定的页面,如果我直接通过URL登录,该页面运行良好

public void hoverTest() throws Exception {
        act.moveToElement(mouseHover).build().perform();
        ((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", clickPatientSearchPage);
        act.moveToElement(clickPatientSearchPage).click().build().perform();
        log.info("Clicked on Care Management module and selected the 'Patient Search' Page.");
    }
但现在在第一行(act.moveToElement(mouseHover.build().perform();)中出现以下错误

org.openqa.selenium.json.JsonException: java.lang.reflect.InvocationTargetException
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'NAVSTLPC174', ip: '10.200.202.86', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_221'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.json.JsonOutput.convertUsingMethod(JsonOutput.java:332)
    at org.openqa.selenium.json.JsonOutput.lambda$new$16(JsonOutput.java:155)
    at org.openqa.selenium.json.JsonOutput.write(JsonOutput.java:264)
    at org.openqa.selenium.json.JsonOutput.lambda$null$21(JsonOutput.java:168)
    at java.util.LinkedHashMap$LinkedValues.forEach(Unknown Source)
    at org.openqa.selenium.json.JsonOutput.lambda$new$22(JsonOutput.java:168)
    at org.openqa.selenium.json.JsonOutput.write(JsonOutput.java:264)
    at org.openqa.selenium.json.JsonOutput.lambda$null$23(JsonOutput.java:177)
    at com.google.common.collect.SingletonImmutableBiMap.forEach(SingletonImmutableBiMap.java:65)
    at org.openqa.selenium.json.JsonOutput.lambda$new$24(JsonOutput.java:176)
    at org.openqa.selenium.json.JsonOutput.write(JsonOutput.java:264)
    at org.openqa.selenium.json.JsonOutput.write(JsonOutput.java:255)
    at org.openqa.selenium.json.Json.toJson(Json.java:42)
    at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:227)
    at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:117)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:152)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.perform(RemoteWebDriver.java:618)
    at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:639)
    at com.coreoanalytics.pageObjects.DataIntegrationPage_WellMed.hoverTest(DataIntegrationPage_WellMed.java:157)
    at com.coreoanalytics.testCases.DataIntegrationTest_WellMedTest.verifyingMyRoster(DataIntegrationTest_WellMedTest.java:45)
    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:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
    Suppressed: org.openqa.selenium.json.JsonException: Attempting to close incomplete json stream
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'NAVSTLPC174', ip: '10.200.202.86', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_221'
Driver info: driver.version: RemoteWebDriver
        at org.openqa.selenium.json.JsonOutput.close(JsonOutput.java:279)
        at org.openqa.selenium.json.Json.toJson(Json.java:44)
        ... 33 more
Caused by: java.lang.reflect.InvocationTargetException
    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.openqa.selenium.json.JsonOutput.convertUsingMethod(JsonOutput.java:328)
    ... 45 more
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//label[contains(text(),'Care Management')]"}
  (Session info: chrome=86.0.4240.198)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'NAVSTLPC174', ip: '10.200.202.86', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_221'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 86.0.4240.198, chrome: {chromedriverVersion: 86.0.4240.22 (398b0743353ff..., userDataDir: C:\Users\PDHOLA~1\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:59455}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: 19516df441af17b882643708e11cd790
*** Element info: {Using=xpath, value=//label[contains(text(),'Care Management')]}
    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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
    at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
    at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69)
    at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)
    at com.sun.proxy.$Proxy9.getWrappedElement(Unknown Source)
    at org.openqa.selenium.interactions.PointerInput$Origin.asArg(PointerInput.java:204)
    at org.openqa.selenium.interactions.PointerInput$Move.encode(PointerInput.java:155)
    at org.openqa.selenium.interactions.Sequence.encode(Sequence.java:75)
    at org.openqa.selenium.interactions.Sequence.toJson(Sequence.java:84)
    ... 50 more