Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8085827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:15:08+00:00 2026-06-05T18:15:08+00:00

I am trying to set and then read a Cookie using the Selenium Webdriver.

  • 0

I am trying to set and then read a Cookie using the Selenium Webdriver.
Adding Cookie works fine.
However, when I am trying to read the cookie, an exception is thrown by Selenium.

  1. I am using the Java API for Selenium.
  2. The test cases are run using TestNG. ver 5.12
  3. Selenium webdriver-htmlunit version 0.9.7376

Test case code

      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.Cookie;
      .
      .
      .
      WebDriver driver = ....
    // Now set the cookie. This one's valid for the entire domain

    Cookie testCookie = new Cookie.Builder("myCookie", "cookieValue").domain("localhost").path("/").build();
    //Works fine till here
    driver.manage().addCookie(testCookie);

    //breaks here
    String cookieFromBrow = driver.manage().getCookieNamed("myCookie").toString();
    System.out.println("Cookie :- [" + cookieFromBrow + "]");

Stacktrace

java.lang.NoSuchMethodError: org.openqa.selenium.internal.ReturnedCookie.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Date;Z)V
at org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitOptions.getCookies(HtmlUnitDriver.java:851)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitOptions.getCookieNamed(HtmlUnitDriver.java:812)
at com.medomain.site.test.SampleResultPageIntlITCase.initTestPage(SampleResultPageIntlITCase.java:150)
at com.medomain.site.test.SampleResultPageIntlITCase.testFindCaseForm(SampleResultPageIntlITCase.java:123)
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:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:702)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:768)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1022)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)

Any help will be really appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:15:10+00:00Added an answer on June 5, 2026 at 6:15 pm

    The problem is method getSecure() on org.apache.commons.httpclient.Cookie which appears to be missing.

    You seem to have entered the JAR hell and some of your libraries / dependencies in your project conflict with each other in the org.apache.commons.httpclient version. The WebDriver you use wants version 3.1. Check all the dependencies on your project, find the offending library and the version of httpclient that really makes in into your classpath.

    Try to use the newer one of the two – if that doesn’t help, good luck :).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read in a file to my perl script and then set
Trying to set it so if a certain condition is met then one of
I'm trying to hold a set of ID's in an ArrayList I then want
I am trying to do download some images from server then , set these
I'm trying to set up a PHP script to read a handful of MySQL
I'm trying to avoid TIME_WAIT in a client. I connect and then set O_NONBLOCK
I'm trying to set a script that finds the location of bash then uses
I'm trying to read a cookie, but don't have a clue how, basically. The
I am trying to set up Selenium in my Grails project via the Selenium-RC
I'm trying to set up my own http openwrap repository. I've read https://github.com/openrasta/openwrap/wiki/Openwrap-publishing-protocol but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.