Skip to content

Instantly share code, notes, and snippets.

@gempesaw
Created July 3, 2012 20:05
Show Gist options
  • Select an option

  • Save gempesaw/3042607 to your computer and use it in GitHub Desktop.

Select an option

Save gempesaw/3042607 to your computer and use it in GitHub Desktop.
can't create cookies in IE with Se 2.24.1 ?
org.openqa.selenium.WebDriverException: Unable to add cookie to page (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 93 milliseconds
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 17:28:14'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_31'
Driver info: driver.version: RemoteWebDriver
Session ID: 8a7b9bb5-d55e-4e37-985c-86e42b5041f8
Command duration or timeout: 331 milliseconds
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 16:53:24'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.4', java.version: '1.6.0_33'
Driver info: driver.version: RemoteWebDriver
Session ID: 431ce1dfc2cc4096892fdc68e4d8a5ef
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions.addCookie(RemoteWebDriver.java:527)
at TestingSe2Sauce.testSauce(TestingSe2Sauce.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.openqa.selenium.WebDriverException: Unable to add cookie to page (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 93 milliseconds
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 17:28:14'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_31'
Driver info: driver.version: RemoteWebDriver
Session ID: 8a7b9bb5-d55e-4e37-985c-86e42b5041f8
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 16:53:24'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.4', java.version: '1.6.0_33'
Driver info: driver.version: RemoteWebDriver
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:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions.addCookie(RemoteWebDriver.java:527)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringOptions.addCookie(EventFiringWebDriver.java:498)
at org.openqa.selenium.remote.server.handler.AddCookie.call(AddCookie.java:33)
at org.openqa.selenium.remote.server.handler.AddCookie.call(AddCookie.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:150)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
import junit.framework.TestCase;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.*;
import java.net.URL;
import java.util.concurrent.TimeUnit;
public class TestingSe2Sauce extends TestCase {
private WebDriver driver;
public void setUp() throws Exception {
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability("version", "8");
capabilities.setCapability("platform", Platform.XP);
capabilities.setCapability("name", "trying to add a cookie");
// for saucelabs to choose latest
capabilities.setCapability("selenium-version", "2.24.1");
// 10.10.0.8 is my local IP for my remote Windows box that has 2.24.1 running
this.driver = new RemoteWebDriver(
// new URL("REDACTED-SAUCELABS-URL")
new URL("http://10.10.0.8:4444/wd/hub"),
capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
public void testSauce() throws Exception {
this.driver.get("http://saucelabs.com/test/guinea-pig");
this.driver.get("http://saucelabs.com/test/guinea-pig");
assertEquals("I am a page title - Sauce Labs", this.driver.getTitle());
Thread.sleep(5000);
Cookie cookie = new Cookie("key", "value");
this.driver.manage().addCookie(cookie);
}
public void tearDown() throws Exception {
this.driver.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment