How to use new geckodriver endpoints?

The new geckodriver v0.17.0 has a new way to install add-ons, as indicated 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 in firefox for my selenium tests?

+1
source share
2 answers

You need to know the ip and port where geckodriver is running. And as soon as geckodriver starts up, you can get the session ID from the driver instance.

You can get the IP address and port as indicated here

For example: if ip and port are local: 15874

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

json

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

{
    "path":"xxyy.xpi",
    "temporary":true
}
+2

- .NET- ( )

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
+1

Source: https://habr.com/ru/post/1680958/


All Articles