IMHO it's usually better to write a WebExtension instead of using Selenium, since you have more control over the browser, can intercept and modify network requests, can access the DOM from JavaScript while being protected from the page altering the environment, and can ship the code as a browser add-on, while still being able to communicate with native apps.<p>Only downside is that you can't drive old IE and mobile browsers except for Firefox for Android.