1
votes

I use Perl and Selenium / Webdriver to write user interface tests. I know that I can use the Selenium::Firefox::Profile module to create profiles for Firefox.

I would like to use my default profile, or one created with Firefox profile manager. Is it possible to use an existing Firefox profile for tests?

This doesn't work:

my $ff_profile = Selenium::Firefox::Profile->new('default-1480098066829');

my $driver = Selenium::Remote::Driver->new(
    'remote_server_addr' => 'localhost',
    'browser_name'       => 'firefox',
    'firefox_profile'    => $ff_profile,
    'port'               => '5555',
    'marionette_enabled' => 1,
);

My default profile accepts a self-signed SSL certificate for an intranet page which must be tested. When Webdriver opens the page with a new profile, it fails because of Firefox certificate dialog.

If I cannot use my default profile, is there some way to add this certificate to Webdriver's new profile?

1
So many times we see doesn't work as an explanation of the problem, and I don't understand why. No one ever called their service station and asked "My car doesn't work; what do you think is wrong?" So why does software get treated the same way? Could you also say what you mean by "it fails because of Firefox certificate dialog"? - Borodin
Firefox will show a warning page for an unknown self signed certificate, This page leads to webdriver error: Error while executing command: get: An unknown server-side error occurred while processing the command.: Reached error page: about:certerror?e=nssBadCert&u=https://... - Fabian_Z071
And what call call does your software make to raise the error, and what is the return value and error string? - Borodin

1 Answers

0
votes

I have no experience using Selenium::Firefox::Profile, but looking at the source, it doesn't offer any way of using the settings of an existing profile, but will always use Firefox's default settings, and allow changes to be made to that by calls to set_preference and set_boolean_preference

What is clear is the the new constructor expects only a hash of parameters, and the only significant element of that hash has the key profile_dir

That means that your call Selenium::Firefox::Profile->new('default-1480098066829') will have resulted in

odd number of elements in hash assignment

which you should have reported when you asked for help. If you didn't see that message then you don't have use warnings in place, which would be pretty shabby of you

You could try Selenium::Firefox::Profile->new( profile_dir => '<my Firefox profile folder>' ), but I would be surprised if that changes much. By default, the module uses File::Temp to create a new temporary folder and puts the new profile in there

You will probably have to find the names of the options that are missing from the default profile and add them explicitly, unless someone more knowledgeable than me has a better idea