Page 1 of 1

Connect to already running instance of Firefox using Selenium

Posted: 21 Oct 2019, 03:54
by ankitkraken
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!

Re: Connect to already running instance of Firefox using Selenium

Posted: 26 Oct 2019, 08:40
by malcev
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()