获取错误java.lang.ClassCastException:org.openqa.selenium.remote.SessionId无法强制转换为javax.servlet.http.HttpSession

时间:2015-09-26 23:15:54

标签: selenium selenium-webdriver

public class DevProject
{
    SessionId sessionId;
    WebDriver driver;
    String baseUrl, nodeURL;

    @BeforeTest
    public void setUp() throws MalformedURLException
    {
        baseUrl = "http://www.google.com";
        nodeURL = "http://192.168.1.3:5566/wd/hub";

        DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
        capability.setBrowserName("firefox");
        capability.setPlatform(Platform.VISTA);

        driver = new RemoteWebDriver(new URL(nodeURL), capability);
    }

    @Test
    public void simpleTest()
    {
        driver.get(baseUrl);
        sessionId = ((RemoteWebDriver) driver).getSessionId();
        HttpSession httpSession = null;
        httpSession = (HttpSession) sessionId;
        System.out.println("my session " + httpSession.toString());
        System.out.println("my session " + sessionId.toString());
    }
}

无法将Selenium会话标记为javax.servlet.http.HttpSession。我想使用httpSession = (HttpSession) sessionId;,但它会抛出错误

  

java.lang.ClassCastException:org.openqa.selenium.remote.SessionId无法强制转换为javax.servlet.http.HttpSession

0 个答案:

没有答案