, ,

Firefox WebDriver Newsletter — 117

Posted by

WebDriver is a remote control interface that enables introspection and control of user agents. As such it can help developers to verify that their websites are working and performing well with all major browsers. The protocol is standardized by the W3C and consists of two separate specifications: WebDriver classic (HTTP) and the new WebDriver BiDi (Bi-Directional).

This newsletter gives an overview of the work we’ve done as part of the Firefox 117 release cycle

Contributions

With Firefox being an open source project, we are grateful to get contributions from people outside of Mozilla.

No new contribution to mention for release 117, but we already have a few planned for release 118. It’s really easy to get started!

WebDriver code is written in JavaScript, Python, and Rust so any web developer can contribute! Read how to setup the work environment and check the list of mentored issues for Marionette and geckodriver.

WebDriver BiDi

Firefox 117 comes with a lot of new WebDriver BiDi features. We made several improvements to existing commands and events, but this release also contains several new commands and events.

New: “browser.close” command

Clients using only WebDriver BiDi can now cleanly close the browser and terminate all WebDriver sessions by using the browser.close command. It will return before closing the WebSocket connection, so it can be used as any other command. browser.close takes no argument and has no return value.

New: “browsingContext.setViewport” command

The browsingContext.setViewport command allows users to change the characteristics of the viewport of a specific browsing context. The command supports a viewport parameter with width and height properties, which will set the dimensions of the viewport. It can be useful to emulate narrow viewports or test responsive design.

Viewport resized to 480x640 using browsingContext.setViewport

To restore the viewport afterwards, simply call the command without passing the viewport parameter and the default dimensions will be re-applied.

New: “browsingContext.fragmentNavigated” event

browsingContext.fragmentNavigated is a new event which will be emitted for a same-document navigation, for instance when navigating to an anchor of the current document. The payload of this event is a browsingContext.NavigationInfo, similar to the existing browsingContext events load and domContentLoaded.

Support for “background” argument in browsingContext.create

A new argument background is now supported for browsingContext.create. When background is set to true, the new context (tab or window) will be opened in the background. This argument is optional and defaults to false.

More importantly, this means browsingContext.create now opens contexts in the foreground by default, whereas they were always in the background before. This should make it easier to handle new tabs and windows, until we support browsingContext.activate to change the selected context dynamically (which is coming soon).

Support for “clip” argument in browsingContext.captureScreenshot

The clip argument for browsingContext.captureScreenshot allows to restrict the screenshot to a specific area or to a specific element. clip can either be a browsingContext.BoxClipRectangle or a browsingContext.ElementClipRectangle. The BoxClipRectangle expects viewport coordinates (x, y) and dimensions (width, height). ElementClipRectangle expects at least an element property, and you can also provide a scrollIntoView boolean to make sure the element is visible before capturing the screenshot. This can be especially useful for component visual regression testing.

Screenshot made using the clip argument of captureScreenshot

Support for navigation id in several commands and events

Starting with Firefox 117, all events and commands which relate to a navigation should now provide a non-null navigation id. This id is a UUID which identifies a specific page navigation and will help to identify events and commands linked to a single navigation. The navigation property is now available in the response of the browsingContext.navigate command, as well as in the payload of the following events: browsingContext.domContentLoaded, browsingContext.load, browsingContext.fragmentNavigated, network.beforeRequestSent, network.responseStarted, network.responseCompleted. Note that for network events, the navigation property will only be set for the initial request of a navigation, not for subsequent requests triggered by the page load.

Bug fixes

Firefox 117 also comes with a few bug fixes, including:

Marionette (WebDriver classic)

There are no updates for Marionette and WebDriver Classic in Firefox 117.

Leave a Reply

Your email address will not be published. Required fields are marked *