![](/img/trans.png)
[英]How to open an browser using the same session in Selenium Webdriver?
[英]How to Extract and use the JSESSIONID cookie from firefox browser using selenium webdriver to use same session.
我正在使用Selenium Web驱动程序进行UI自动化,我想测试在UI中填充数据的Web服务。 在遍历UI时,我想测试用此Web服务的UI元素填充的数据。 但是selenium不支持调用Web服务,因此我使用的是http客户端,但是由于这是两个不同的应用程序,因此我想对selenium Web驱动程序和HTTP客户端使用相同的会话。 我正在使用Firebox作为浏览器。
//Assume Wed Driver is initiated properly
Cookie cookie= driver.manage().getCookieNamed("JSESSIONID");
System.out.println(cookie.getValue());
您可以从firebug中提取JSESSIONID cookie值,然后在httpClient中设置setNameer(“ Cookie”,“ JSESSIONID =” + getSessionId())之类的“ Cookie”标头,以在每个请求中发送它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.