Dear esteemed PerlMonks

I am using the Perl Selenium package, WWW::Selenium.

Trying to resize the browser window, I am getting a mysterious JavaScript error: "Threw an exception: missing ; before statement".

Here is the code:

use strict; use warnings; use 5.014; use autodie; use warnings qw< FATAL utf8 >; use Carp; use Carp::Always; use WWW::Selenium; my $url = q{http://www.google.com}; #for example my $sel = WWW::Selenium->new( host => 'localhost', port => 4444, browser => '*firefox F:\WIN 7 programs\Web & Internet\Firefox 8 bit +\firefox.exe', browser_url => $url, ); $sel->open( $url ); $sel->wait_for_page_to_load(10000); my $res = $sel->window_maximize(); # So far, this works fine $res = $sel->get_eval( q{ WebDriver driver = ((WebDriverBackedSelenium +) selenium).getWrappedDriver(); driver.manage().window().setSize(1040,768);} ); # (Following this: http://stackoverflow.com/questions/1522252/, Eli + Colner's post)

The program then crashes here with: "Threw an exception: missing ; before statement"

If I drop the first JavaScript line and just leave in the 2nd line, namely:

$res = $sel->get_eval( q{driver.manage().window().setSize(1040,720);} );

It bumps with: "driver not defined".

Help will be appreciated - Thanks in advance

Helen

Note: cross posted here:
http://stackoverflow.com/questions/24585497/


In reply to Selenium: Trying to resize window from Perl: getting a mysterious JavaScript error by HelenCr

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.