无法使用Selenium在Chrome浏览器中添加Cookie

时间:2019-06-14 07:14:20

标签: java selenium cookies automation

我想绕过“登录”页面,因此,我首先登录Web应用程序并将Cookies存储到Cookies.Data文件中,然后使用相同的Cookies文件,使用String标记器检索数据并将cookie添加到chrome中。通过将Cookie(名称,值,域,路径,日期,安全)传递给浏览器。

       org.openqa.selenium.WebDriverException: unable to set cookie   (Session info: chrome=74.0.3729.169)   (Driver info:
     

chromedriver = 2.43.600210   (68dcf5eebde37173d4027fa8635e332711d2874a),平台= Windows NT   10.0.17763 x86_64)(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:0毫秒生成信息:   版本:“ 3.14.0”,修订版:“ aacccce0”,时间:   '2018-08-02T20:19:58.91Z'系统信息:主机:'MTL071',IP:   '10 .250.1.201',操作系统名称:'Windows 10',os.arch:'amd64',操作系统版本:   '10 .0',java.version:'1.8.0_201'驱动程序信息:   org.openqa.selenium.chrome.ChromeDriver功能   {acceptInsecureCerts:否,acceptSslCerts:否,   applicationCacheEnabled:否,browserConnectionEnabled:否,   browserName:chrome,chrome:{chromedriver版本:2.43.600210   (68dcf5eebde371 ...,userDataDir:C:\ Users \ RAGHUr \ AppData \ Loc ...},   cssSelectorsEnabled:true,databaseEnabled:false,goog:chromeOptions:   {debuggerAddress:localhost:54755},handlesAlerts:true,   hasTouchScreen:false,javascriptEnabled:true,   locationContextEnabled:true,mobileEmulationEnabled:false,   nativeEvents:true,networkConnectionEnabled:false,pageLoadStrategy:   正常,平台:XP,平台名称:XP,可旋转:false,   setWindowRect:true,takesHeapSnapshot:true,takesScreenshot:true,   UnexpectedAlertBehaviour:,unhandledPromptBehavior:,版本:   74.0.3729.169,webStorageEnabled:true}会话ID:7f612d67d16796cabdf7578471840e2d,网址为   sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)     在sun.reflect.NativeConstructorAccessorImpl.newInstance(未知   来源)   sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知   源)位于java.lang.reflect.Constructor.newInstance(未知源)     在   org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)     在   org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)     在   org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)     在   org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)     在   org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)     在   org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)     在   org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)     在   org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)     在   org.openqa.selenium.remote.RemoteWebDriver $ RemoteWebDriverOptions.addCookie(RemoteWebDriver.java:678)     在Utility.Common.writeCookies(Common.java:215)在   ARATest.MainTest.beforeMethod(MainTest.java:131)在   sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)位于   sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)位于   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知源)位于   java.lang.reflect.Method.invoke(来源未知)   org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)     在   org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)     在   org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:455)     在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)     在org.testng.internal.Invoker.invokeMethod(Invoker.java:520)处   org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)在   org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)在
  org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)     在   org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)     在org.testng.TestRunner.privateRun(TestRunner.java:648)处   org.testng.TestRunner.run(TestRunner.java:505)在   org.testng.SuiteRunner.runTest(SuiteRunner.java:455)在   org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)在   org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)在   org.testng.SuiteRunner.run(SuiteRunner.java:364)在   org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)在   org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)在   org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)在   org.testng.TestNG.runSuitesLocally(TestNG.java:1137)在   org.testng.TestNG.runSuites(TestNG.java:1049)在   org.testng.TestNG.run(TestNG.java:1017)在   org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)     在org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)         在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

0 个答案:

没有答案