Connect to already running instance of Firefox using Selenium

Get help with using AutoHotkey and its commands and hotkeys
User avatar
ankitkraken
Posts: 70
Joined: 01 Jun 2019, 08:47
Location: India

Connect to already running instance of Firefox using Selenium

21 Oct 2019, 03:54

Hi,

Using the following command we can connect to the already running instance of Chrome (in debug mode). Is there any way to achieve the same thing for Firefox?

Code: Select all

ChromeGet(IP_Port := "127.0.0.1:9222") {
     
     driver := ComObjCreate("Selenium.CHROMEDriver") ;Chrome driver
     
     driver.SetCapability("debuggerAddress", IP_Port)
     driver.Start()
     
     return driver
}
driver := ChromeGet()
Thanks!
malcev
Posts: 258
Joined: 12 Aug 2014, 12:37

Re: Connect to already running instance of Firefox using Selenium

26 Oct 2019, 08:40

I think with -start-debugger-server port.
https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#-start-debugger-server_port
But current version of this Selenium wrapper supports Firefox only till 46 version.
If You need support the last Firefox version You have to write wrapper by Yourself, using this info
https://www.w3.org/TR/webdriver/
and this
https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-9102019/
For example to run new instance of firefox and navigate to google.com can be done like this

Code: Select all

Run, geckodriver.exe
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("POST", "http://127.0.0.1:4444/session", true)
HTTP.Send("{}")
HTTP.WaitForResponse()
sessionId := RegexReplace(HTTP.responseText, "^.+?sessionId"":""(.+?)"".+$", "$1")
HTTP.Open("POST", "http://127.0.0.1:4444/session/" sessionId "/url", true)
HTTP.Send("{""url"":""http://google.com""}")
HTTP.WaitForResponse()

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], satdeath and 174 guests