3

The new geckodriver v0.17.0 has a new way to install addons as mentioned here:

POST /session/{session id}/window/fullscreen to invoke the window manager-specific full screen operation
POST /session/{session id}/moz/addon/install to install an extension [Gecko only]
POST /session/{session id}/moz/addon/uninstall to uninstall an extension [Gecko only]

How can I use these endpoints to install my addon to firefox for my selenium tests?

mosaad
  • 2,276
  • 5
  • 27
  • 49

2 Answers2

4

You have to know the ip and port in which geckodriver starts. And Once the geckodriver started you can get the Session Id from the driver Instance.

You can get the Ip Address and Port as mentioned here

For ex: if the ip and port is
localhost:15874

and session id is 1e53412a-05eb-40a9-8a7b-bb8dd6fd75ab

Then you can post a json message to

http://localhost:15874/session/1e53412a-05eb-40a9-8a7b-bb8dd6fd75ab/moz/addon/install

The body of post message should be

{
    "path":"xxyy.xpi",
    "temporary":true
}
Madhan
  • 5,750
  • 4
  • 28
  • 61
1

In case somebody need to use this from .NET client (as it is not yet implemented)

Public Class MyFirefoxDriver
Inherits OpenQA.Selenium.Firefox.FirefoxDriver

Public Sub New(fo As OpenQA.Selenium.Firefox.FirefoxOptions)
    MyBase.New(fo)
    MyBase.CommandExecutor.CommandInfoRepository.TryAddCommand("moz-install-web-ext", New CommandInfo(CommandInfo.PostCommand, "/session/{sessionId}/moz/addon/install"))
End Sub


Public Sub InstallWebExtension(path As String)
    Dim params As New Dictionary(Of String, Object)
    params.Add("path", path)
    params.Add("temporary", True)
    MyBase.Execute("moz-install-web-ext", params)
End Sub

End Class
hex
  • 713
  • 1
  • 11
  • 17