简体   繁体   English

如何使用selenium webdriver从firefox浏览器中提取和使用JSESSIONID cookie,以使用同一会话。

[英]How to Extract and use the JSESSIONID cookie from firefox browser using selenium webdriver to use same session.

I am working on the UI Automation using a selenium web driver, I want to test the web services which are filling data in the UI. 我正在使用Selenium Web驱动程序进行UI自动化,我想测试在UI中填充数据的Web服务。 When I traverse through the UI, I want to test the data which are filled with the UI element of this web service. 在遍历UI时,我想测试用此Web服务的UI元素填充的数据。 But selenium doesn't support calling web services, so I am using http client, but as this is two different applications I want to use the same session for selenium web driver and HTTP client. 但是selenium不支持调用Web服务,因此我使用的是http客户端,但是由于这是两个不同的应用程序,因此我想对selenium Web驱动程序和HTTP客户端使用相同的会话。 I am using the firebox as my browser. 我正在使用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.

相关问题 如何在Selenium Webdriver中使用相同的会话打开浏览器? - How to open an browser using the same session in Selenium Webdriver? 如何在java中使用TestNG Selenium webdriver在多个类中使用相同的浏览器窗口? - How to use the same browser window in multiple classes using TestNG Selenium webdriver in java? 如何使用Selenium WebDriver从Xpath提取数值 - How to use selenium webdriver to extract numeric values from Xpath 届时会话将使浏览器中的jsessionid cookie无效 - remove jsessionid cookie from browser at that time session is going to invalidate 正则表达式:如何从Cookie字符串中提取JSESSIONID Cookie值? - Regex: how to extract a JSESSIONID cookie value from cookie string? 无法使用Selenium WebDriver连接到Firefox浏览器? - Unable to connect to firefox browser using selenium webdriver? 如何从Dojo中的XHR请求中提取JSESSIONID cookie? - How do you extract the JSESSIONID cookie from an XHR request in Dojo? 如何强制Selenium与WebDriver一起使用永久Firefox配置文件? - How to Force Selenium to use Permanent Firefox Profiles with WebDriver? 如何使用Java在Selenium Webdriver中为Firefox配置文件使用相对文件路径? - How to use relative file path for firefox profile in Selenium webdriver using java? 如何从设置了HttpOnly标志的浏览器中删除JSESSIONID cookie - How delete the JSESSIONID cookie from the browser with HttpOnly flag set
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM