gempesaw 11 лет назад
Родитель
Сommit
30a76d3915

+ 7 - 8
Changes

@@ -15,7 +15,7 @@ Revision history for Selenium-Remote-Driver
 
         [NEW FEATURES]
         - Merged Test::WebDriver into this distribution as Test::Selenium::Remote::Driver.
-          Several updates to it are included since the last release. (Mark Stosberg)   
+          Several updates to it are included since the last release. (Mark Stosberg)
 
         - The existence of most (or all?) key testing methods in
           Test::Selenium::Remote::Driver is now documented, rather than leaving it to users
@@ -32,7 +32,7 @@ Revision history for Selenium-Remote-Driver
              type_element_ok   - find an element and type into it.
              element_text_is   - find an element and check the text.
              element_value_is  - find an element and check the value.
-             click_element_ok  - find an element and click on it. 
+             click_element_ok  - find an element and click on it.
              clear_element_ok  - find an element and clear it.
              is_element_displayed_ok - find an element and check to see if it's displayed.
              is_element_enabled_ok - find an element and check to see if it's enabled.
@@ -50,7 +50,7 @@ Revision history for Selenium-Remote-Driver
            https://github.com/aivaturi/Selenium-Remote-Driver/pull/49
 
         - new() now accepts a 'webelement_class' option to allow you to specify an alternate WebElement class.
-          This could be used to add testing methods or functionality for WebElements.  
+          This could be used to add testing methods or functionality for WebElements.
 
         - Shortcut methods absorbed from Test::WebDriver into Selenium::Remote::Driver:
 
@@ -59,9 +59,9 @@ Revision history for Selenium-Remote-Driver
           get_path() Returns the path part of the current URL.
 
         - New short method to save a screenshot to a file: $driver->capture_screenshot($filename).
-          The name was chosen for compatibility with a WWW::Selenium method of the same name.  
+          The name was chosen for compatibility with a WWW::Selenium method of the same name.
 
-        - Removed 'get_location()' as an alias in Test::Selenium::Remote::Driver. 
+        - Removed 'get_location()' as an alias in Test::Selenium::Remote::Driver.
           Please use the more specific 'get_current_url()' instead.
           It's a more specific name that matches the Selenium API method name.
 
@@ -168,7 +168,7 @@ Revision history for Selenium-Remote-Driver
         - Added method get_sessions()
         - Fixed issue #11
         - Fixed documentation from issue #21
-        
+
 0.13   2-8-2012
         - Added support for key events in send_keys() method
         - Added methods to get/set window position/size
@@ -187,7 +187,7 @@ Revision history for Selenium-Remote-Driver
 
 0.11   8-16-2011
   This is quite a large list for this release and will be
-  the first cpan release. The later releases will hopefully 
+  the first cpan release. The later releases will hopefully
   happen often and won't be quite as large.
 
         - subroutine calls carp when an error occurs or when
@@ -238,4 +238,3 @@ Revision history for Selenium-Remote-Driver
         - Added POD for Driver & WebElement
 0.01    2-21-2010
         First version, released on an unsuspecting world.
-

+ 3 - 3
lib/Selenium/Remote/Driver.pm

@@ -129,7 +129,7 @@ available here.
         'auto_close'           - <boolean>  - whether driver should end session on remote server on close.
         'default_finder'       - <string>   - choose default finder used for find_element* {class|class_name|css|id|link|link_text|name|partial_link_text|tag_name|xpath}
         'extra_capabilities'   - HASH of extra capabilities
-        'webelement_class'     - <string>   - sub-class of Selenium::Remote::WebElement if you wish to use an alternate WebElement class. 
+        'webelement_class'     - <string>   - sub-class of Selenium::Remote::WebElement if you wish to use an alternate WebElement class.
         'proxy'                - HASH       - Proxy configuration with the following keys:
             'proxyType' - <string> - REQUIRED, Possible values are:
                 direct     - A direct connection                                                                    - no proxy in use,
@@ -169,8 +169,8 @@ available here.
     my $driver = Selenium::Remote::Driver->new('browser_name'       => 'chrome',
                                               'platform'           => 'VISTA',
                                               'extra_capabilities' => {'chrome.switches' => ["--user-data-dir=$ENV{LOCALAPPDATA}\\Google\\Chrome\\User Data"],
-                                              							'chrome.prefs' => {'download.default_directory' =>'/home/user/tmp', 'download.prompt_for_download' =>1 }
-                                              							},
+                                                                                                'chrome.prefs' => {'download.default_directory' =>'/home/user/tmp', 'download.prompt_for_download' =>1 }
+                                                                                                },
                                               );
     or
     my $driver = Selenium::Remote::Driver->new('proxy' => {'proxyType' => 'manual', 'httpProxy' => 'myproxy.com:1234'});

+ 3 - 3
lib/Selenium/Remote/ErrorHandler.pm

@@ -111,13 +111,13 @@ has STATUS_CODE => (
 
 # Instead of just returning the end user a server returned error code, we will
 # put a more human readable & usable error message & that is what this method
-# is going to do. 
+# is going to do.
 sub process_error {
     my ($self, $resp) = @_;
     # TODO: Handle screen if it sent back with the response. Either we could
     # let the end user handle it or we can save it an image file at a temp
-    # location & return the path. 
-    
+    # location & return the path.
+
     my $ret;
     $ret->{'stackTrace'} = $resp->{'value'}->{'stackTrace'};
     $ret->{'error'} = $self->STATUS_CODE->{$resp->{'status'}};

+ 21 - 21
lib/Selenium/Remote/RemoteConnection.pm

@@ -10,31 +10,31 @@ use JSON;
 use Data::Dumper;
 use Selenium::Remote::ErrorHandler;
 
-has 'remote_server_addr' => ( 
-    is => 'rw', 
-); 
+has 'remote_server_addr' => (
+    is => 'rw',
+);
 
-has 'port' => ( 
-    is => 'rw', 
+has 'port' => (
+    is => 'rw',
 );
 
-has 'debug' => ( 
-    is => 'rw', 
-    default => sub { 0 } 
+has 'debug' => (
+    is => 'rw',
+    default => sub { 0 }
 );
 
-has 'ua' => ( 
-    is => 'lazy', 
+has 'ua' => (
+    is => 'lazy',
     builder => sub { return LWP::UserAgent->new; }
 );
- 
-sub BUILD { 
-    my $self = shift; 
-    my $status; 
-    try { 
+
+sub BUILD {
+    my $self = shift;
+    my $status;
+    try {
       $status = $self->request('GET','status');
-    } 
-    catch { 
+    }
+    catch {
         croak "Could not connect to SeleniumWebDriver: $_" ;
     };
     if($status->{cmd_status} ne 'OK') {
@@ -78,7 +78,7 @@ sub request {
         $json->allow_blessed;
         $content = $json->allow_nonref->utf8->encode($params);
     }
-    
+
     print "REQ: $url, $content\n" if $self->debug;
 
     # HTTP request
@@ -110,7 +110,7 @@ sub _process_response {
             $decoded_json = $json->allow_nonref(1)->utf8(1)->decode($response->content);
             $data->{'sessionId'} = $decoded_json->{'sessionId'};
         }
-        
+
         if ($response->is_error) {
             my $error_handler = new Selenium::Remote::ErrorHandler;
             $data->{'cmd_status'} = 'NOTOK';
@@ -118,7 +118,7 @@ sub _process_response {
                 $data->{'cmd_return'} = $error_handler->process_error($decoded_json);
             }
             else {
-                $data->{'cmd_return'} = 'Server returned error code '.$response->code.' and no data';          
+                $data->{'cmd_return'} = 'Server returned error code '.$response->code.' and no data';
             }
             return $data;
         }
@@ -128,7 +128,7 @@ sub _process_response {
                 $data->{'cmd_return'} = $decoded_json->{'value'};
             }
             else {
-                $data->{'cmd_return'} = 'Server returned status code '.$response->code.' but no data';          
+                $data->{'cmd_return'} = 'Server returned status code '.$response->code.' but no data';
             }
             return $data;
         }

+ 19 - 19
lib/Selenium/Remote/WebElement.pm

@@ -16,7 +16,7 @@ provides a mechanism to represent them as objects & perform various actions on
 the related elements. This module should not be instantiated directly by the end
 user. Selenium::Remote::Driver instantiates this module when required. Typically,
 the find_element method in Selenium::Remote::Driver returns this object on which
-various element related operations can be carried out. 
+various element related operations can be carried out.
 
 =cut
 
@@ -82,9 +82,9 @@ sub submit {
  Usage:
     $elem->send_keys('abcd', 'efg');
     $elem->send_keys('hijk');
-    
+
     or
-    
+
     # include the WDKeys module
     use Selenium::Remote::WDKeys;
     .
@@ -126,7 +126,7 @@ sub is_selected {
 =head2 set_selected
 
  Description:
-    Select an OPTION element, or an INPUT element of type checkbox or radiobutton. 
+    Select an OPTION element, or an INPUT element of type checkbox or radiobutton.
 
  Usage:
     $elem->set_selected();
@@ -146,7 +146,7 @@ sub set_selected {
  Description:
     Toggle whether an OPTION element, or an INPUT element of type checkbox or
     radiobutton is currently selected.
-    
+
  Output:
     BOOLEAN - Whether the element is selected after toggling its state.
 
@@ -167,7 +167,7 @@ sub toggle {
 
  Description:
     Determine if an element is currently enabled.
-    
+
  Output:
     BOOLEAN - Whether the element is enabled.
 
@@ -187,7 +187,7 @@ sub is_enabled {
  Description:
    Determine an element's location on the page. The point (0, 0) refers to the
    upper-left corner of the page.
-    
+
  Output:
     HASH - The X and Y coordinates for the element on the page.
 
@@ -207,10 +207,10 @@ sub get_element_location {
  Description:
     Determine an element's location on the screen once it has been scrolled
     into view.
-    
+
     Note: This is considered an internal command and should only be used to
     determine an element's location for correctly generating native events.
-    
+
  Output:
     {x:number, y:number} The X and Y coordinates for the element on the page.
 
@@ -229,7 +229,7 @@ sub get_element_location_in_view {
 
  Description:
     Query for an element's tag name.
-    
+
  Output:
     STRING - The element's tag name, as a lowercase string.
 
@@ -248,7 +248,7 @@ sub get_tag_name {
 
  Description:
     Clear a TEXTAREA or text INPUT element's value.
-    
+
  Usage:
     $elem->clear();
 
@@ -268,7 +268,7 @@ sub clear {
  Input: 1
     Required:
         STRING - name of the attribute of the element
-    
+
  Output:
     {STRING | NULL} The value of the attribute, or null if it is not set on the element.
 
@@ -312,7 +312,7 @@ sub get_value {
 
  Description:
     Determine if an element is currently displayed.
-    
+
  Output:
     BOOLEAN - Whether the element is displayed.
 
@@ -337,7 +337,7 @@ sub is_displayed {
     Required:
         NUMBER - X axis distance in pixels
         NUMBER - Y axis distance in pixels
-    
+
  Usage:
     $elem->drag(216,158);
 
@@ -364,7 +364,7 @@ sub drag {
 
  Output:
     HASH - The width and height of the element, in pixels.
-    
+
  Usage:
     $elem->get_size();
 
@@ -383,7 +383,7 @@ sub get_size {
 
  Output:
     STRING - innerText of an element
-    
+
  Usage:
     $elem->get_text();
 
@@ -408,7 +408,7 @@ sub get_text {
 
  Output:
     STRING - Value of the css attribute
-    
+
  Usage:
     $elem->get_css_attribute('background-color');
 
@@ -478,5 +478,5 @@ distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-480:	hit eof while in pod documentation (no =cut seen)
-	this can cause trouble with some pod utilities
+480:    hit eof while in pod documentation (no =cut seen)
+        this can cause trouble with some pod utilities

+ 2 - 2
lib/Test/Selenium/Remote/Driver.pm

@@ -187,7 +187,7 @@ sub new {
 
 =head2 server_is_running( $host, $port )
 
-Returns true if a Selenium server is running.  The host and port 
+Returns true if a Selenium server is running.  The host and port
 parameters are optional, and default to C<localhost:4444>.
 
 Environment vars C<TWD_HOST> and C<TWD_PORT> can also be used to
@@ -705,7 +705,7 @@ sub is_element_displayed_ok {
 
     $twd->is_element_enabled_ok($search_target [,$desc]);
 
-Find an element and check to confirm that it is enabled. 
+Find an element and check to confirm that it is enabled.
 
 =cut
 

+ 18 - 18
lib/Test/Selenium/Remote/WebElement.pm

@@ -10,10 +10,10 @@ has _builder => (
     handles => [qw/is_eq isnt_eq like unlike ok croak/],
 );
 
-sub has_args { 
-    my $self = shift; 
-    my $fun_name = shift; 
-    my $hash_fun_args = { 
+sub has_args {
+    my $self = shift;
+    my $fun_name = shift;
+    my $hash_fun_args = {
         'get_attribute' => 1,
     };
     return ($hash_fun_args->{$fun_name} // 0);
@@ -27,12 +27,12 @@ sub _check_method {
     $method = "get_$method";
     my @args = @_;
     my $rv;
-    try { 
+    try {
         my $num_of_args = $self->has_args($method);
         my @r_args = splice (@args,0,$num_of_args);
         $rv = $self->$method(@r_args);
     }
-    catch { 
+    catch {
         $self->croak($_);
     };
     # +2 because of the delegation on _builder
@@ -40,15 +40,15 @@ sub _check_method {
     return $self->$method_to_test( $rv, @args );
 }
 
-sub _check_ok { 
-    my $self = shift; 
-    my $meth = shift; 
+sub _check_ok {
+    my $self = shift;
+    my $meth = shift;
     my $test_name = pop // $meth;
     my $rv;
-    try { 
+    try {
         $rv = $self->$meth(@_);
     }
-    catch { 
+    catch {
         $self->croak($_);
     };
 
@@ -57,37 +57,37 @@ sub _check_ok {
     return $self->ok($rv,$test_name,@_);
 }
 
-sub clear_ok { 
+sub clear_ok {
     my $self = shift;
     return $self->_check_ok('clear',@_);
 }
 
-sub click_ok { 
+sub click_ok {
     my $self = shift;
     return $self->_check_ok('click',@_);
 }
 
-sub submit_ok { 
+sub submit_ok {
     my $self = shift;
     return $self->_check_ok('submit',@_);
 }
 
-sub is_selected_ok { 
+sub is_selected_ok {
     my $self = shift;
     return $self->_check_ok('is_selected',@_);
 }
 
-sub is_enabled_ok { 
+sub is_enabled_ok {
     my $self = shift;
     return $self->_check_ok('is_enabled',@_);
 }
 
-sub is_displayed_ok { 
+sub is_displayed_ok {
     my $self = shift;
     return $self->_check_ok('is_displayed',@_);
 }
 
-sub send_keys_ok { 
+sub send_keys_ok {
     my $self = shift;
     return $self->_check_ok('send_keys',@_);
 }

+ 1 - 1
t/Test-Selenium-Remote-Driver-google.t

@@ -8,7 +8,7 @@ unless ($host and $port) {
     exit 0;
 }
 
-# Try to find 
+# Try to find
 my $t = Test::Selenium::Remote::Driver->new(
     remote_server_addr => $host, port => $port,
 );

+ 3 - 3
t/Test-Selenium-Remote-Driver.t

@@ -41,7 +41,7 @@ my $element = Test::Selenium::Remote::WebElement->new(
 {
     $successful_driver->mock('find_element', sub { $element } );
     check_tests(
-      sub { 
+      sub {
           my $rc = $successful_driver->find_element_ok('q', 'find_element_ok works');
           is($rc,1,'returns true');
       },
@@ -61,7 +61,7 @@ my $element = Test::Selenium::Remote::WebElement->new(
 
     $successful_driver->mock('find_element', sub { 0 } );
     check_tests(
-      sub { 
+      sub {
           my $rc = $successful_driver->find_element_ok('q', 'find_element_ok works, falsey test');
           is($rc,0,'returns false');
       },
@@ -84,7 +84,7 @@ my $element = Test::Selenium::Remote::WebElement->new(
 {
     $successful_driver->mock('find_element', sub { die } );
     check_tests(
-      sub { 
+      sub {
           my $rc = $successful_driver->find_no_element_ok('BOOM', 'find_no_element_ok works, expecting to find nothing.');
           is($rc,1,'returns true');
       },