Seleniu...Profile(3)
β¨ Selenium::Firefox::Profile β¨
Ok so bestie, you know Selenium::Firefox::Profile? It's the User Contributed Perl Documentation page for it, and honestly it's a whole vibe. Let me walk you through it π«Ά
π VERSION π
version 1.49 β that's the one, periodt.
πΈ DESCRIPTION πΈ
You can use this module to create a custom Firefox Profile for your Selenium tests. Currently, you can set browser preferences and add extensions to the profile before passing it in the constructor for a new Selenium::Remote::Driver or Selenium::Firefox. That's it, that's the whole flex. π
π¦ SYNPOSIS π¦
(yes the page spells it like that, we don't judge, we're just quoting the icon)
use Selenium::Remote::Driver;
use Selenium::Firefox::Profile;
my $profile = Selenium::Firefox::Profile->new;
$profile->set_preference(
'browser.startup.homepage' => 'http://www.google.com',
'browser.cache.disk.capacity' => 358400
);
$profile->set_boolean_preference(
'browser.shell.checkDefaultBrowser' => 0
);
$profile->add_extension('t/www/redisplay.xpi');
my $driver = Selenium::Remote::Driver->new(
'firefox_profile' => $profile
);
$driver->get('http://www.google.com');
print $driver->get_title();
Look at her go π a whole Firefox profile built from scratch.
π CONSTRUCTOR π
new (%args)
profile_dirβ a<string>directory to look for the firefox profile. Defaults to a Tempdir.
Literally just hand her the args and she'll build you a fresh little profile. π§
π₯ METHODS π₯
set_preference
Sets string and integer preferences on the profile object. You can set multiple preferences at once, bestie, no need to do them one at a time. If you need to set a boolean preference, either use JSON::true/JSON::false, or go see set_boolean_preference() instead.
$profile->set_preference("quoted.integer.pref" => '"20140314220517"');
# user_pref("quoted.integer.pref", "20140314220517");
$profile->set_preference("plain.integer.pref" => 9005);
# user_pref("plain.integer.pref", 9005);
$profile->set_preference("string.pref" => "sample string value");
# user_pref("string.pref", "sample string value");
See how the quoted one stays quoted? That's not a typo, that's the point π
set_boolean_preference
For the prefs that need a boolean value of true or false. Yes you can set multiple at once here too. For string or integer prefs, go use set_preference() instead, don't mix them up.
$profile->set_boolean_preference("false.pref" => 0);
# user_pref("false.pref", false);
$profile->set_boolean_preference("true.pref" => 1);
# user_pref("true.pref", true);
1 and 0 in, true and false out. Iconic conversion behaviour, no cap. β
get_preference
Gets the computed value of a preference. Strings come back double quoted, and boolean values come back single quoted as "true" or "false" accordingly.
$profile->set_boolean_preference("true.pref" => 1);
print $profile->get_preference("true.pref") # true
$profile->set_preference("string.pref" => "an extra set of quotes");
print $profile->get_preference("string.pref") # "an extra set of quotes"
Yeah the string gets an extra set of quotes. That's the behaviour, we're not making the rules, we're just reporting them πΈ
add_extension
Adds an existing .xpi to the profile β just give it the path. β οΈ Heads up though: this only works with packaged .xpi files, not plain/un-packed extension directories. So don't come crying to me with a folder, ok?
$profile->add_extension('t/www/redisplay.xpi');
add_webdriver
Primarily for internal use β sets the appropriate firefox preferences for a new geckodriver session. Not your main character, but she's doing important work backstage π«Ά
add_webdriver_xpi
Primarily for internal use. This adds the fxgoogle .xpi that is used for webdriver communication in FF47 and older. For FF48 and newer, the old method of using an extension to orchestrate the webdriver communication with the Firefox browser has been obsoleted by the introduction of "geckodriver". So if you're on new Firefox, that whole approach is giving legacy, bestie π
add_marionette
Primarily for internal use β configures Marionette to the current Firefox profile. Again, internal, but slay for her π
π SEE ALSO π
http://kb.mozillazine.org/About:config_entrieshttps://developer.mozilla.org/en-US/docs/Mozilla/Preferences/A_brief_guide_to_Mozilla_preferences
Go read up, it's giving lore π
π AUTHORS π
Current Maintainers:
- George S. Baugh <george@troglodyne.net>
Previous maintainers:
- Daniel Gempesaw <gempesaw@gmail.com>
- Emmanuel PeroumalnaΓ―k <peroumalnaik.emmanuel@gmail.com>
- Luke Closs <cpan@5thplane.com>
- Mark Stosberg <mark@stosberg.com>
Original authors:
- Aditya Ivaturi <ivaturi@gmail.com>
Shoutout to the whole lineage, fr fr π
π COPYRIGHT AND LICENSE π
Copyright (c) 2010-2011 Aditya Ivaturi, Gordon Child
Copyright (c) 2014-2017 Daniel Gempesaw
Copyright (c) 2018-2021 George S. Baugh
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
And that's the whole page, bestie πβ¨ sign-off time: this lil doc was generated by perl v5.42.0 on 2023-04-07, and it's literally still serving Seleniu...Profile(3) energy. Periodt. π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Selenium-Remote-Driver 1.49-bp160.1.4 Β· Apache-2.0
- opensuse-leap 16.0: perl-Selenium-Remote-Driver 1.49-bp160.1.4 Β· Apache-2.0
- opensuse-leap 16.0: perl-Selenium-Remote-Driver 1.49-bp160.1.4 Β· Apache-2.0
- opensuse-leap 16.0: perl-Selenium-Remote-Driver 1.49-bp160.1.4 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms