How to access Firefox Extension I added in Selenium Webdriver?
It depends on extension. Usually the extension's behaviour can be to some extent controlled by setting appropriate properties (the ones you can find in about:config) when creating an FF profile. For instance to have Firebug window open by default after FF starts I would include the following line in my code:
default_profile["extensions.firebug.allPagesActivation"] = true
The extensions I use usually have some kind of auto-export feature that automatically sends data to server or saves it on disk. I am afraid there is no way of controlling an extension with WebDriver so not all extensions will be usable in automated tests.
How to add extension in firefox driver in Java using selenium
Try with FF68,selenium-java 4.0.0-alpha-2 and v0.24.0 . Tested on Windows machine.
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File("foxyproxy_basic-5.5-an+fx.xpi"));
options.setProfile(profile);
Is there a way to add extension on startup firefox with selenium on nodejs?
With the latest version I could get this to work.
However, I think firefox.Profile
has been removed as now it will by default run with an anonymous profile (see https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/firefox)
E.g. in my example below I take a screenshot which shows the dark reader extension working.
const {Builder} = require('selenium-webdriver');
const fs = require('fs');
const firefox = require('selenium-webdriver/firefox');
(async function example() {
let options = new firefox.Options().addExtensions('dark_reader-4.9.32-an+fx.xpi');
let driver = await new Builder()
.forBrowser('firefox')
.setFirefoxOptions(options)
.build();
try {
await driver.get('https://google.com/');
await new Promise(resolve => setTimeout(resolve, 5000));
const image = await driver.takeScreenshot();
fs.writeFileSync('out.png', image, { encoding: 'base64' })
} finally {
await driver.quit();
}
})();
Related Topics
Sudo Gem Install Pg Won't Work
Count the Length (Number of Lines) of a CSV File
In Ruby, Should I Use ||= or If Defined? for Memoization
Deleting While Iterating in Ruby
Active Admin Scopes for Each Instance of a Related Model
Ruby on Rails - Devise Users/Sign_Out Not Working
How to Find a Devise User by It's Session Id
Rails Ssl Issue: (Https://Example.Com) Didn't Match Request.Base_Url (Http://Example.Com)
Counting Days Excluding Weekends
Ruby: Build Failed (Macos 11.2 Using Ruby-Build 20210119) MAC Big Sur
Ruby on Rails: /Bin/Sh: Rspec: Command Not Found
Ruby Symbols VS Strings in Hashes
Ruby: How to Store and Display a Day of the Week