Hi There!

I am trying to drive the Selenium WebDriver using Perl. The complete context is I am testing on a window10 machine, testing against firefox 50. I have not installed the Selenium server, because I do not need to - the package Selenium::Remote::Driver (available in CPAN) uses the geckodriver. My goal is to open a website, enter texts in the fields, press a button and take a picture - all from using my script.

What I have been able to do so far is the following: I can open a website from the script and can see it open in the window. I can even find a particular element on the screen (in the code snippet a field to accept text and a button) using the xPATH. This runs without error and when I print out the instantiated objects (see below) I get what I am looking for and no errors.

Here is the code - its the commented out lines that are giving me trouble.

#!C:\perl64\bin perl64 -w use Selenium::Remote::Driver; use Selenium::Firefox; use Test::Selenium::Firefox; use Selenium::Remote::WebElement; use Selenium::Remote::WDKeys; print "Starting New\n"; my $driver = Selenium::Firefox->new( marionette_enabled => 1, firefox_binary => "C:\Program Fil +es (x86)\Mozilla Firefox" ); $driver->get('http://144.76.109.38/peTEST'); #works my $elem = $driver->find_element_by_xpath(".//input[\@id='user_login_n +ame']"); print $elem."\n"; #$elem->send_keys('Superuser'); my $otherElem = $driver->find_element_by_xpath(".//*[\@id='user_login' +]\/tbody\/tr[4]\/td\/table\/tbody\/tr\/td[2]\/input"); print $otherElem."\n"; sleep(15), $driver->shutdown_binary;

When I comment in the send_keys line, I get the following error.

Use of uninitialized value in substitution iterator at C:/Perl64/site/ +lib/Selenium/Remote/Commands.pm at line 437 Use of uninitialized value in has element at C:/Perl64/site/lib/Seleni +um/Remote/ErrorHandler.pm at line 126 Error while executing command sendKeysToElement at C:/Perl64/site/lib/ +Selenium/Remote/Driver.pm at line 313. at C:/Perl64/site/lib/Selenium +/Remote/Driver.pm at line 313

I cannot tell if it is my code or not which is causing the problem, and the documentation online in (for example) MetaCPAN ist a bit lacking. I have tried to contact the current Selenium::Remote::Driver guys, but haven't gotten an answer yet.

Here is deal - if we can get this figured out quickly enough, I will do a full scale write up and disseminate the knowledge to the world. OK?

Thanks to all Monks - Tom ("novice")


In reply to Need Help with Selenium and Perl by proarchcon

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.