ソースを参照

Work around selenium not providing the full path to a file in some cases

George S. Baugh 11 年 前
コミット
dcfe16c507
1 ファイル変更11 行追加1 行削除
  1. 11 1
      lib/Selenium/Remote/Driver.pm

+ 11 - 1
lib/Selenium/Remote/Driver.pm

@@ -20,6 +20,8 @@ use Scalar::Util;
 use Selenium::Remote::RemoteConnection;
 use Selenium::Remote::Commands;
 use Selenium::Remote::WebElement;
+use File::Spec::Functions ();
+use File::Basename ();
 
 use constant FINDERS => {
     class             => 'class name',
@@ -2369,7 +2371,15 @@ sub upload_file {
     my $params = {
         file => MIME::Base64::encode_base64($string)          # base64-encoded string
     };
-    return $self->_execute_command( $res, $params );
+    my $ret = $self->_execute_command( $res, $params );
+
+    #WORKAROUND: Since this is undocumented selenium functionality, work around a bug.
+    my ($drive, $path, $file) = File::Spec::Functions::splitpath($ret);
+    if ($file ne $filename) {
+        $ret = File::Spec::Functions::catpath($drive,$path,$filename);
+    }
+
+    return $ret;
 }
 
 =head2 get_text