Pārlūkot izejas kodu

Add unit tests for upload_file method.

George S. Baugh 11 gadi atpakaļ
vecāks
revīzija
f303afff19
4 mainītis faili ar 19 papildinājumiem un 0 dzēšanām
  1. 6 0
      t/01-driver.t
  2. 11 0
      t/mock-recordings/01-driver-mock-linux.json
  3. 1 0
      t/uploadTest
  4. 1 0
      uploadTest

+ 6 - 0
t/01-driver.t

@@ -497,6 +497,12 @@ LOGS: {
     }
 }
 
+UPLOAD: {
+    #Webdriver only returns the full filename if there isn't any path components in it, so test both cases
+    like( $driver->upload_file('uploadTest'),qr/uploadTest$/,'upload_file returns FULL path to the file: cwd');
+    like( $driver->upload_file('t/uploadTest'),qr/uploadTest$/,'upload_file returns FULL path to the file: subdir');
+}
+
 QUIT: {
     $ret = $driver->quit();
     ok((not defined $driver->{'session_id'}), 'Killed the remote session');

+ 11 - 0
t/mock-recordings/01-driver-mock-linux.json

@@ -246,7 +246,18 @@
    "POST session/27145e62-ea82-4fb8-90c3-3ae03e3fbebd/url {\"url\":\"http://localhost:63636/alerts.html\"}" : [
       "HTTP/1.1 200 OK\nCache-Control: no-cache\nCache-Control: no-cache\nConnection: close\nDate: Tue, 20 Jan 2015 14:42:27 GMT\nServer: Jetty/5.1.x (Linux/3.2.0-23-generic-pae i386 java/1.7.0_51\nContent-Length: 156\nContent-Type: application/json; charset=utf-8\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\nClient-Date: Tue, 20 Jan 2015 14:42:27 GMT\nClient-Peer: 127.0.0.1:4444\nClient-Response-Num: 1\n\n{\"sessionId\":\"27145e62-ea82-4fb8-90c3-3ae03e3fbebd\",\"status\":0,\"state\":\"success\",\"value\":null,\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":4321325}\n"
    ],
+<<<<<<< HEAD
    "GET session/cf63db5c-b56f-4eb2-8113-31ed985d5f6a/window/current/size {}" : [
       "HTTP/1.1 200 OK\nCache-Control: no-cache\nCache-Control: no-cache\nConnection: close\nDate: Tue, 20 Jan 2015 14:42:33 GMT\nServer: Jetty/5.1.x (Linux/3.2.0-23-generic-pae i386 java/1.7.0_51\nContent-Length: 238\nContent-Type: application/json; charset=utf-8\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\nClient-Date: Tue, 20 Jan 2015 14:42:33 GMT\nClient-Peer: 127.0.0.1:4444\nClient-Response-Num: 1\n\n{\"sessionId\":\"cf63db5c-b56f-4eb2-8113-31ed985d5f6a\",\"status\":0,\"state\":\"success\",\"value\":{\"height\":747,\"width\":480,\"class\":\"org.openqa.selenium.Dimension\",\"hCode\":-268435456},\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":14510672}\n"
+=======
+   "POST session/36fe41df-65fc-4f99-bcb0-3cad4b8c6f2d/execute {\"args\":[\"checky\"],\"script\":\"\\n          var arg1 = arguments[0];\\n          var elem = window.document.getElementById(arg1);\\n          return elem;\\n        \"}" : [
+      "HTTP/1.1 200 OK\nCache-Control: no-cache\nCache-Control: no-cache\nConnection: close\nDate: Wed, 05 Nov 2014 04:44:10 GMT\nServer: Jetty/5.1.x (Linux/3.2.0-23-generic-pae i386 java/1.7.0_51\nContent-Length: 168\nContent-Type: application/json; charset=utf-8\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\nClient-Date: Wed, 05 Nov 2014 04:44:10 GMT\nClient-Peer: 127.0.0.1:4444\nClient-Response-Num: 1\n\n{\"status\":0,\"sessionId\":\"36fe41df-65fc-4f99-bcb0-3cad4b8c6f2d\",\"value\":{\"ELEMENT\":\"0\"},\"state\":\"success\",\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":26539503}\n"
+   ],
+   "POST session/36fe41df-65fc-4f99-bcb0-3cad4b8c6f2d/file {\"file\":\"UEsDBBQACAAIAAR0M0YAAAAAAAAAAAAAAAAMABUAdC91cGxvYWRUZXN0VVQJAANTbL1UyGm9VFV4\\nBADoA+gDK0ktLuECAFBLBwjGNbk7BwAAAAUAAABQSwECFAMUAAgACAAEdDNGxjW5OwcAAAAFAAAA\\nDAANAAAAAAAAAAAApIEAAAAAdC91cGxvYWRUZXN0VVQFAAFTbL1UVXgAAFBLBQYAAAAAAQABAEcA\\nAABWAAAAAAA=\\n\"}" : [
+      "HTTP/1.1 200 OK\nCache-Control: no-cache\nCache-Control: no-cache\nConnection: close\nDate: Mon, 19 Jan 2015 21:08:27 GMT\nServer: Jetty/5.1.x (Linux/3.13.0-43-generic amd64 java/1.7.0_65\nContent-Length: 229\nContent-Type: application/json; charset=utf-8\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\nClient-Date: Mon, 19 Jan 2015 21:08:27 GMT\nClient-Peer: 192.168.122.26:4444\nClient-Response-Num: 1\n\n{\"sessionId\":\"36fe41df-65fc-4f99-bcb0-3cad4b8c6f2d\",\"status\":0,\"state\":\"success\",\"value\":\"/tmp/ffacbf13-4890-49cc-a61e-92eb7a59ff95/upload5692048746335716335file/t\",\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":925394417}\n"
+   ],
+    "POST session/36fe41df-65fc-4f99-bcb0-3cad4b8c6f2d/file {\"file\":\"UEsDBBQACAAIAKh5M0YAAAAAAAAAAAAAAAAKABUAdXBsb2FkVGVzdFVUCQADcXO9VGxzvVRVeAQA\\n6APoAytJLS7hAgBQSwcIxjW5OwcAAAAFAAAAUEsBAhQDFAAIAAgAqHkzRsY1uTsHAAAABQAAAAoA\\nDQAAAAAAAAAAAKSBAAAAAHVwbG9hZFRlc3RVVAUAAXFzvVRVeAAAUEsFBgAAAAABAAEARQAAAFQA\\nAAAAAA==\\n\"}" : [
+      "HTTP/1.1 200 OK\nCache-Control: no-cache\nCache-Control: no-cache\nConnection: close\nDate: Mon, 19 Jan 2015 21:14:33 GMT\nServer: Jetty/5.1.x (Linux/3.13.0-43-generic amd64 java/1.7.0_65\nContent-Length: 239\nContent-Type: application/json; charset=utf-8\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\nClient-Date: Mon, 19 Jan 2015 21:14:33 GMT\nClient-Peer: 192.168.122.26:4444\nClient-Response-Num: 1\n\n{\"sessionId\":\"36fe41df-65fc-4f99-bcb0-3cad4b8c6f2d\",\"status\":0,\"state\":\"success\",\"value\":\"/tmp/b172f61c-3c28-48dd-a8f3-bdfafd0d7169/upload2815452634228483073file/uploadTest\",\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":1511467738}\n"
+>>>>>>> Add unit tests for upload_file method.
    ]
 }

+ 1 - 0
t/uploadTest

@@ -0,0 +1 @@
+test

+ 1 - 0
uploadTest

@@ -0,0 +1 @@
+test