Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_window_size $height/$width cast problem #141

Closed
ricdainf opened this issue Jun 25, 2014 · 3 comments
Closed

set_window_size $height/$width cast problem #141

ricdainf opened this issue Jun 25, 2014 · 3 comments
Assignees
Milestone

Comments

@ricdainf
Copy link

Perl 5.18.2
Platform ubuntu 14.4
Using selenium 2.41 in standalone mode returned Exception :
23:44:32.589 WARN - Exception thrown
org.openqa.selenium.WebDriverException: Illegal (non-numeric) window width value passed: 1024
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'darkstar', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-29-generic', java.version: '1.7.0_60'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.handler.SetWindowSize.setJsonParameters(SetWindowSize.java:41)

json created is :
{"width":"1024","height":"1280"}
instead of :
{"width":1024,"height":1280}

sub set_window_size {
    my ( $self, $height, $width, $window ) = @_;
    $window = ( defined $window ) ? $window : 'current';
    if ( not defined $height and not defined $width ) {
        croak "height & width of browser are required";
    }
####   PATCH  #####
    $height+=0;
    $width+=0;
####   PATCH  #####
    my $res = { 'command' => 'setWindowSize', 'window_handle' => $window };
    my $params = { 'height' => $height, 'width' => $width };
    my $ret = $self->_execute_command( $res, $params );
    if ( $ret =~ m/204/g ) {
        return 1;
    }
    else { return 0; }
}

Trying to pass casted values to subroutine have no result, suppose "my ( $self, $height, $width, $window ) = @_;" assignment resets the numeric data type to scalar raw

@gempesaw gempesaw self-assigned this Jul 3, 2014
@gempesaw gempesaw added this to the 0.2003 milestone Jul 3, 2014
@gempesaw
Copy link
Collaborator

I haven't been able to replicate this anywhere (os x, linux, windows, 6 versions of perl on travis-ci), but I don't haven't tried exact environment that have. I'm working on putting a vagrant box together with your exact env...

@gempesaw
Copy link
Collaborator

@ricdainf Still haven't been able to reproduce this, but again, I'm still not on your exact environment yet. Which version of the Selenium::Remote::Driver bindings are you using? With my local version, I'm seeing the following debug output

REQ: POST, session/9c6946b1-334e-4df7-91ca-4e8a46f3653f/window/current/size, {"width":1280,"height":1024}
RES: {"status":0,"sessionId":"9c6946b1-334e-4df7-91ca-4e8a46f3653f","value":null,"state":"success","class":"org.openqa.selenium.remote.Response","hCode":1402753096}

when running this test script

#!/usr/bin/perl

use strict;
use warnings;
use Selenium::Remote::Driver;

my $driver = Selenium::Remote::Driver->new;
$driver->debug_on;
$driver->set_window_size(1024, 1280);
$driver->debug_off;

Do you see a similar result ?

@gempesaw gempesaw modified the milestones: 0.2003, 0.23 Oct 29, 2014
gempesaw added a commit that referenced this issue Jan 25, 2015
        [NEW FEATURES]
        - #178 Fix upload_file's return value & add test suite
        - #179 Add optional middle finder-strategy argument to T:S:R:D's find_element-like functions
        - #174 Add new endpoints: cache status, geolocation, log types, orientation, etc

        [BUG FIXES]
        - #175 Fix find_elements
        - #180 Stop overwriting body_text_unlike test descriptions
        - #141 Explicitly cast height and weight to integers for set_window_size
@gempesaw
Copy link
Collaborator

Thanks! Now on cpan as v0.23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants