UNPKG

1.76 kBJavaScriptView Raw
1// Licensed to the Software Freedom Conservancy (SFC) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The SFC licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18'use strict';
19
20var WebDriver = require('..').WebDriver,
21 assert = require('../testing/assert'),
22 test = require('../lib/test'),
23 Pages = test.Pages;
24
25
26test.suite(function(env) {
27 var browsers = env.browsers;
28
29 var driver;
30 test.before(function*() {
31 driver = yield env.builder().build();
32 });
33
34 test.after(function() {
35 return driver.quit();
36 });
37
38 test.it('can connect to an existing session', function*() {
39 yield driver.get(Pages.simpleTestPage);
40 yield assert(driver.getTitle()).equalTo('Hello WebDriver');
41
42 return driver.getSession().then(session1 => {
43 let driver2 = WebDriver.attachToSession(
44 driver.getExecutor(),
45 session1.getId());
46
47 return assert(driver2.getTitle()).equalTo('Hello WebDriver')
48 .then(_ => {
49 let session2Id = driver2.getSession().then(s => s.getId());
50 return assert(session2Id).equalTo(session1.getId());
51 });
52 });
53 });
54});