소스 검색

Add broken, wip test for phantomjs & chrome binary startup

Daniel Gempesaw 10 년 전
부모
커밋
a321b2d103
2개의 변경된 파일48개의 추가작업 그리고 0개의 파일을 삭제
  1. 34 0
      t/binary.t
  2. 14 0
      t/mock-recordings/binary-mock-darwin.json

+ 34 - 0
t/binary.t

@@ -0,0 +1,34 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+use Selenium::Binary;
+use Selenium::Chrome;
+use Selenium::PhantomJS;
+
+use FindBin;
+use lib $FindBin::Bin . '/lib';
+use TestHarness;
+
+my $harness = TestHarness->new(
+    this_file => $FindBin::Script
+);
+my %caps = %{ $harness->base_caps };
+delete $caps{browser_name};
+
+PHANTOMJS: {
+    my $ghost = Selenium::PhantomJS->new( %caps );
+    is( $ghost->browser_name, 'phantomjs', 'binary phantomjs is okay');
+    isnt( $ghost->port, 4444, 'phantomjs can start up its own binary');
+}
+
+CHROME: {
+    $ENV{PATH} .= ':/usr/local/lib/node_modules/protractor/selenium';
+    my $chrome = Selenium::Chrome->new( %caps );
+    ok( $chrome->browser_name eq 'chrome', 'convenience chrome is okay' );
+    isnt( $chrome->port, 4444, 'chrome can start up its own binary');
+    $chrome->quit;
+}
+
+done_testing;

+ 14 - 0
t/mock-recordings/binary-mock-darwin.json

@@ -0,0 +1,14 @@
+{
+   "POST session {\"desiredCapabilities\":{\"acceptSslCerts\":true,\"browserName\":\"phantomjs\",\"javascriptEnabled\":true,\"platform\":\"ANY\",\"version\":\"\"}}" : [
+      "HTTP/1.1 200 OK\nCache-Control: no-cache\nCache-Control: no-cache\nConnection: close\nDate: Tue, 10 Mar 2015 20:07:42 GMT\nServer: Jetty/5.1.x (Mac OS X/10.10.2 x86_64 java/1.7.0_67\nContent-Length: 672\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, 10 Mar 2015 20:07:43 GMT\nClient-Peer: 127.0.0.1:4444\nClient-Response-Num: 1\n\n{\"status\":0,\"sessionId\":\"853468b2-1f3c-471b-8bd4-c52590c099ac\",\"state\":null,\"value\":{\"platform\":\"OS X 10.10\",\"acceptSslCerts\":false,\"javascriptEnabled\":true,\"browserName\":\"phantomjs\",\"rotatable\":false,\"driverVersion\":\"1.1.0\",\"locationContextEnabled\":false,\"webdriver.remote.sessionid\":\"853468b2-1f3c-471b-8bd4-c52590c099ac\",\"version\":\"1.9.8\",\"cssSelectorsEnabled\":true,\"databaseEnabled\":false,\"handlesAlerts\":false,\"browserConnectionEnabled\":false,\"webStorageEnabled\":false,\"nativeEvents\":true,\"proxy\":{\"proxyType\":\"direct\"},\"applicationCacheEnabled\":false,\"driverName\":\"ghostdriver\",\"takesScreenshot\":true},\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":368790224}\n"
+   ],
+   "DELETE session/853468b2-1f3c-471b-8bd4-c52590c099ac {}" : [
+      "HTTP/1.1 200 OK\nCache-Control: no-cache\nCache-Control: no-cache\nConnection: close\nDate: Tue, 10 Mar 2015 20:07:43 GMT\nServer: Jetty/5.1.x (Mac OS X/10.10.2 x86_64 java/1.7.0_67\nContent-Length: 159\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, 10 Mar 2015 20:07:44 GMT\nClient-Peer: 127.0.0.1:4444\nClient-Response-Num: 1\n\n{\"status\":0,\"sessionId\":\"853468b2-1f3c-471b-8bd4-c52590c099ac\",\"state\":\"success\",\"value\":null,\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":1184840538}\n"
+   ],
+   "POST session {\"desiredCapabilities\":{\"acceptSslCerts\":true,\"browserName\":\"chrome\",\"javascriptEnabled\":true,\"platform\":\"ANY\",\"version\":\"\"}}" : [
+      "HTTP/1.1 200 OK\nCache-Control: no-cache\nCache-Control: no-cache\nConnection: close\nDate: Tue, 10 Mar 2015 20:07:47 GMT\nServer: Jetty/5.1.x (Mac OS X/10.10.2 x86_64 java/1.7.0_67\nContent-Length: 746\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, 10 Mar 2015 20:07:48 GMT\nClient-Peer: 127.0.0.1:4444\nClient-Response-Num: 1\n\n{\"status\":0,\"sessionId\":\"9f6c7379-395e-43f0-826f-b5c84e16c304\",\"state\":null,\"value\":{\"platform\":\"MAC\",\"acceptSslCerts\":true,\"javascriptEnabled\":true,\"browserName\":\"chrome\",\"chrome\":{\"userDataDir\":\"/var/folders/19/fy4zlkw13c160qyl6h5px_dh55vrly/T/.org.chromium.Chromium.qcJfQ6\"},\"rotatable\":false,\"locationContextEnabled\":true,\"mobileEmulationEnabled\":false,\"webdriver.remote.sessionid\":\"9f6c7379-395e-43f0-826f-b5c84e16c304\",\"version\":\"41.0.2272.89\",\"takesHeapSnapshot\":true,\"cssSelectorsEnabled\":true,\"databaseEnabled\":false,\"handlesAlerts\":true,\"browserConnectionEnabled\":false,\"nativeEvents\":true,\"webStorageEnabled\":true,\"applicationCacheEnabled\":false,\"takesScreenshot\":true},\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":1754929591}\n"
+   ],
+   "DELETE session/9f6c7379-395e-43f0-826f-b5c84e16c304 {}" : [
+      "HTTP/1.1 200 OK\nCache-Control: no-cache\nCache-Control: no-cache\nConnection: close\nDate: Tue, 10 Mar 2015 20:07:48 GMT\nServer: Jetty/5.1.x (Mac OS X/10.10.2 x86_64 java/1.7.0_67\nContent-Length: 159\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, 10 Mar 2015 20:07:48 GMT\nClient-Peer: 127.0.0.1:4444\nClient-Response-Num: 1\n\n{\"status\":0,\"sessionId\":\"9f6c7379-395e-43f0-826f-b5c84e16c304\",\"state\":\"success\",\"value\":null,\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":1422956632}\n"
+   ]
+}