简体   繁体   English

如何在WebDriver中使用已打开的浏览器活动会话

[英]How to use already opened browser active session in webdriver

Is there any way to inherit a session into webdriver? 有什么方法可以将会话继承到webdriver中吗? I did lot of search and know it that selenium does not support connecting to already opened browser. 我做了很多搜索,并知道硒不支持连接到已经打开的浏览器。 It would be better if i could. 如果可以的话会更好。 But now I have thought about some work around. 但是现在我已经考虑过一些解决方法。 Actually my application starts with a shortcut file which launch firefox, hit the application URL, made the log in, go to the dashboard and leave for the user to use it. 实际上,我的应用程序以一个快捷方式文件开头,该文件启动firefox,点击应用程序URL,进行登录,进入仪表板,然后让用户使用它。 In that case i do not need to work on that opened browser, if i can get that active session only and set it while opening the webdriver with selenium then my purpose is solved. 在那种情况下,我不需要在打开的浏览器上工作,如果我只能获得该活动会话并在使用硒打开webdriver时进行设置,那么我的目的就可以解决。 Even its possible manually also. 甚至可以手动操作。 As selenium always open incognito webdriver window, i am unable to get that session there. 由于selenium始终打开隐身WebDriver窗口,因此无法在那里进行会话。 Can any one tell me how to get that session from already opened browser and use it in webdriver? 谁能告诉我如何从已打开的浏览器获取该会话并在webdriver中使用它? Any help or suggestion would be highly appreciated. 任何帮助或建议,将不胜感激。

Selenium is just a server which accepts http requests using the json wire protocol. Selenium只是一个使用json有线协议接受HTTP请求的服务器。 https://code.google.com/p/selenium/wiki/JsonWireProtocol It's an http API. https://code.google.com/p/selenium/wiki/JsonWireProtocol这是一个HTTP API。

Each call in the json wire protocol adds a sessionId parameter to the request. json有线协议中的每个调用都会在请求中添加一个sessionId参数。

So if you start a session using a driver, you can save that session ID and then instantiate a new driver object and give it the sessionId from before. 因此,如果您使用驱动程序启动会话,则可以保存该会话ID,然后实例化一个新的驱动程序对象,并从之前为其赋予sessionId。

If the selenium server is still running that session, then it has no idea which driver object you are using when you send in a request. 如果Selenium服务器仍在运行该会话,则在发送请求时不知道正在使用哪个驱动程序对象。 Feel free to have 100 drivers all with the same sessionID at the same time! 随意同时拥有100个具有相同sessionID的驱动程序! :D :d

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Java在WebDriver中使用已打开的浏览器 - How to use already opened browser in webdriver using java 我如何劫持已打开的浏览器会话并将其附加到Webdriver,而不是自己打开浏览器 - How can I hijack an opened browser session and attach it to the Webdriver than opening a browser by itself 在已经打开的firefox上打开webdriver - Open webdriver on a firefox already opened 如何使用selenium webdriver从firefox浏览器中提取和使用JSESSIONID cookie,以使用同一会话。 - How to Extract and use the JSESSIONID cookie from firefox browser using selenium webdriver to use same session. 如何在Selenium中使用已经打开的firefox进行测试 - How to use a already opened firefox for testing in Selenium 如何在已打开的SSL Session java中打开ssl socket - How to open ssl socket in already opened SSL Session java 单击按钮后,WebDriver切换到浏览器已打开 - WebDriver switch to browser opened after click on button 如何在Selenium Webdriver中使用相同的会话打开浏览器? - How to open an browser using the same session in Selenium Webdriver? 如何使用WebDriver中的Java将浏览器的控件带到新打开的选项卡 - How can I take a browser's control to a newly opened tab using Java in WebDriver 如何将可移植文档格式(PDF)内容类型添加到WebDriver打开的Firefox浏览器的应用程序中 - How to add Portable Document Format (PDF) content type to Application of Firefox browser opened by WebDriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM