Learned brethren,

I have installed Selenium::Firefox on my linux machine. I have also installed the Firefox browser, geckodriver binary and Xvfb so Firefox can run pseudo-headlessly and a Selenium server is not required. I am trying to run the simplest test script:

use strict; use warnings; use feature 'say'; use Carp::Always; use Selenium::Firefox; my $driver = Selenium::Firefox->new; say 'Binary mode: ' . $driver->binary_mode; $driver->get('http://www.google.com'); say $driver->get_title; $driver->shutdown_binary; __END__
The module appears to behave as documented in so far as it finds and launches the relevant binaries, according to the process table:
vagrant 1885 00:03 /usr/local/sbin/geckodriver --port 9090 --m +arionette-port 2828 --binary /usr/lib/firefox/firefox.sh vagrant 1890 00:02 /usr/lib/firefox/firefox --marionette --pro +file /tmp/rust_mozprofile.Bezoxqxkgze8 vagrant 1933 00:01 /usr/lib/firefox/plugin-container -greomni +/usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -a +ppdir /usr/lib/firefox/browser 1890 true tab
But it just hangs then throws an exception when I run it with:
DISPLAY=:42 perl test/selenium.pl
I get the following error:
Could not create new session: at .../lib/perl5/Selenium/Remote/Driver +.pm line 428.
Working back using the stack trace as a map I found that the code for creating a session in Selenium::Remote::Driver is executed regardless of condition from within BUILD. I can't see any place where that is overridden by the class that extends it (Selenium::Firefox), even though use of that class should by definition rule out a session with the Selenium server.
if ($self->has_desired_capabilities) { $self->new_desired_session( $self->desired_capabilities ); } else { # Connect to remote server & establish a new session $self->new_session( $self->extra_capabilities ); }

I confess I am a bit lost a this point. Thanks for any tips!


The way forward always starts with a minimal test.

In reply to Selenium::Firefox (on Linux): create session error, but why? by 1nickt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.