Get fun using the Firefox unit test system
What do you think that is most fun and powerful?
Marionette is the remote protocol that lets out-of-process programs communicate with, instrument, and control Gecko-based browsers.
It provides interfaces for interacting with both the internal JavaScript runtime and UI elements of Gecko-based browsers, such as Firefox and Fennec. It can control both the chrome- and content documents, giving a high level of control and ability to replicate, or emulate, user interaction.
https://firefox-source-docs.mozilla.org/testing/marionette/marionette/
pip install marionette_driver
marionette.enabled -> true
marionette.port -> 2828
./firefox -marionette
Marionette is a bridge that use sockets internally to communicate with Firefox and require a specific Firefox build.
Offers a full control of Firefox also of other stuff that are not included in DevTools protocol because it is used in Firefox for testing.
Also it is the same technology used on the various Firefox version like Firefox for Android.
Marionette is an implementation of the WebDriver standard but wrapped in this "framework" that is stable, require only a supported Firefox version.
As Mozillian (and many other in this room) we prefer to use Mozilla technologies like Firefox DevTools.
I try to do the same also on my daily job in my (little) company.
How many of you evangelism about Mozilla technologies during your daily tasks?
Let's see different tools that I did for my job but also to help other OpenSource communities with Marionette.
headless
modefrom marionette_driver.marionette import Marionette
from marionette_driver import By, Actions
# Connect to Firefox
client = Marionette(host='localhost', port=2828)
client.start_session()
[...]
posts = client.find_elements(By.CSS_SELECTOR, 'td.title a.row-title')
for post in posts:
Actions(client).middle_click(post).perform()
[...]
export.write(client.page_source.encode('utf-8'))
[...]
client.switch_to_window(client.window_handles[-1])
You can also inject JavaScript, switch between tabs to change the focus, autofill username/password etc.
Daniele Scasciafratte - @Mte90Net
Slides: https://mte90.tech/Talk-Marionette/