1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | 'use strict';
|
19 |
|
20 | const webdriver = require('..'),
|
21 | proxy = require('../proxy'),
|
22 | safari = require('../safari'),
|
23 | assert = require('../testing/assert'),
|
24 | test = require('../lib/test');
|
25 |
|
26 |
|
27 | describe('safari.Options', function() {
|
28 | describe('fromCapabilities', function() {
|
29 | it('returns a new Options instance if none were defined', function() {
|
30 | let options = safari.Options.fromCapabilities(
|
31 | new webdriver.Capabilities());
|
32 | assert(options).instanceOf(safari.Options);
|
33 | });
|
34 |
|
35 | it('returns the options instance if present', function() {
|
36 | let options = new safari.Options().setCleanSession(true),
|
37 | caps = options.toCapabilities();
|
38 | assert(safari.Options.fromCapabilities(caps)).equalTo(options);
|
39 | });
|
40 |
|
41 | it('extracts supported WebDriver capabilities', function() {
|
42 | let proxyPrefs = proxy.direct(),
|
43 | logPrefs = {},
|
44 | caps = webdriver.Capabilities.chrome()
|
45 | .set(webdriver.Capability.PROXY, proxyPrefs)
|
46 | .set(webdriver.Capability.LOGGING_PREFS, logPrefs);
|
47 |
|
48 | let options = safari.Options.fromCapabilities(caps);
|
49 | assert(options.proxy_).equalTo(proxyPrefs);
|
50 | assert(options.logPrefs_).equalTo(logPrefs);
|
51 | });
|
52 | });
|
53 |
|
54 | describe('toCapabilities', function() {
|
55 | let options;
|
56 |
|
57 | before(function() {
|
58 | options = new safari.Options()
|
59 | .setCleanSession(true);
|
60 | });
|
61 |
|
62 | it('returns a new capabilities object if one is not provided', function() {
|
63 | let caps = options.toCapabilities();
|
64 | assert(caps).instanceOf(webdriver.Capabilities);
|
65 | assert(caps.get('browserName')).equalTo('safari');
|
66 | assert(caps.get('safari.options')).equalTo(options);
|
67 | });
|
68 |
|
69 | it('adds to input capabilities object', function() {
|
70 | let caps = webdriver.Capabilities.safari();
|
71 | assert(options.toCapabilities(caps)).equalTo(caps);
|
72 | assert(caps.get('safari.options')).equalTo(options);
|
73 | });
|
74 |
|
75 | it('sets generic driver capabilities', function() {
|
76 | let proxyPrefs = proxy.direct(),
|
77 | loggingPrefs = {};
|
78 |
|
79 | options
|
80 | .setLoggingPrefs(loggingPrefs)
|
81 | .setProxy(proxyPrefs);
|
82 |
|
83 | let caps = options.toCapabilities();
|
84 | assert(caps.get('proxy')).equalTo(proxyPrefs);
|
85 | assert(caps.get('loggingPrefs')).equalTo(loggingPrefs);
|
86 | });
|
87 | });
|
88 | });
|
89 |
|
90 | test.suite(function(env) {
|
91 | describe('safaridriver', function() {
|
92 | let service;
|
93 |
|
94 | afterEach(function() {
|
95 | if (service) {
|
96 | return service.kill();
|
97 | }
|
98 | });
|
99 |
|
100 | it('can start safaridriver', function() {
|
101 | service = new safari.ServiceBuilder().build();
|
102 |
|
103 | return service.start().then(function(url) {
|
104 | assert(url).matches(/127\.0\.0\.1/);
|
105 | });
|
106 | });
|
107 | });
|
108 | }, {browsers: ['safari']});
|