diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-24 15:10:37 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-24 15:11:17 +0200 |
commit | 7a3df06eb573d36142bd1a8e03c5ce8752d300b3 (patch) | |
tree | 70bfaea8884c374876f607774850a3a51c0cb381 /node_modules/selenium-webdriver/test | |
parent | aca1143cb9eed16cf37f04e475e4257418dd18ac (diff) |
fix build issues and add typedoc
Diffstat (limited to 'node_modules/selenium-webdriver/test')
3 files changed, 134 insertions, 3 deletions
diff --git a/node_modules/selenium-webdriver/test/lib/by_test.js b/node_modules/selenium-webdriver/test/lib/by_test.js index 1669ec917..34314fbf8 100644 --- a/node_modules/selenium-webdriver/test/lib/by_test.js +++ b/node_modules/selenium-webdriver/test/lib/by_test.js @@ -88,6 +88,27 @@ describe('by', function() { }); describe('checkedLocator', function() { + it('accepts a By instance', function() { + let original = by.By.name('foo'); + let locator = by.checkedLocator(original); + assert.strictEqual(locator, original); + }); + + it('accepts custom locator functions', function() { + let original = function() {}; + let locator = by.checkedLocator(original); + assert.strictEqual(locator, original); + }); + + // See https://github.com/SeleniumHQ/selenium/issues/3056 + it('accepts By-like objects', function() { + let fakeBy = {using: 'id', value: 'foo'}; + let locator = by.checkedLocator(fakeBy); + assert.strictEqual(locator.constructor, by.By); + assert.equal(locator.using, 'id'); + assert.equal(locator.value, 'foo'); + }); + it('accepts class name', function() { let locator = by.checkedLocator({className: 'foo'}); assert.equal('css selector', locator.using); diff --git a/node_modules/selenium-webdriver/test/lib/http_test.js b/node_modules/selenium-webdriver/test/lib/http_test.js index 2dd27869d..7cb0050f7 100644 --- a/node_modules/selenium-webdriver/test/lib/http_test.js +++ b/node_modules/selenium-webdriver/test/lib/http_test.js @@ -293,7 +293,14 @@ describe('http', function() { }); it('auto-upgrades on W3C response', function() { - var rawResponse = {sessionId: 's123', value: {name: 'Bob'}}; + let rawResponse = { + value: { + sessionId: 's123', + value: { + name: 'Bob' + } + } + }; send.returns(Promise.resolve( new http.Response(200, {}, JSON.stringify(rawResponse)))); @@ -344,7 +351,8 @@ describe('http', function() { }); it('handles w3c new session failures', function() { - let rawResponse = {error: 'no such element', message: 'oops'}; + let rawResponse = + {value: {error: 'no such element', message: 'oops'}}; send.returns(Promise.resolve( new http.Response(500, {}, JSON.stringify(rawResponse)))); @@ -429,7 +437,7 @@ describe('http', function() { }); it('does not auto-upgrade on W3C response', function() { - var rawResponse = {sessionId: 's123', value: {name: 'Bob'}}; + var rawResponse = {value: {sessionId: 's123', value: {name: 'Bob'}}}; send.returns(Promise.resolve( new http.Response(200, {}, JSON.stringify(rawResponse)))); diff --git a/node_modules/selenium-webdriver/test/lib/webdriver_test.js b/node_modules/selenium-webdriver/test/lib/webdriver_test.js index 0a124530e..65fa5193a 100644 --- a/node_modules/selenium-webdriver/test/lib/webdriver_test.js +++ b/node_modules/selenium-webdriver/test/lib/webdriver_test.js @@ -1952,6 +1952,108 @@ describe('WebDriver', function() { }); }); + describe('manage()', function() { + describe('setTimeouts()', function() { + describe('throws if no timeouts are specified', function() { + let driver; + before(() => driver = new FakeExecutor().createDriver()); + + it('; no arguments', function() { + assert.throws(() => driver.manage().setTimeouts(), TypeError); + }); + + it('; ignores unrecognized timeout keys', function() { + assert.throws( + () => driver.manage().setTimeouts({foo: 123}), TypeError); + }); + + it('; ignores positional arguments', function() { + assert.throws( + () => driver.manage().setTimeouts(1234, 56), TypeError); + }); + }); + + describe('throws timeout is not a number, null, or undefined', () => { + let driver; + before(() => driver = new FakeExecutor().createDriver()); + + function checkError(e) { + return e instanceof TypeError + && /expected "(script|pageLoad|implicit)" to be a number/.test( + e.message); + } + + it('script', function() { + assert.throws( + () => driver.manage().setTimeouts({script: 'abc'}), + checkError); + }); + + it('pageLoad', function() { + assert.throws( + () => driver.manage().setTimeouts({pageLoad: 'abc'}), + checkError); + }); + + it('implicit', function() { + assert.throws( + () => driver.manage().setTimeouts({implicit: 'abc'}), + checkError); + }); + }); + + it('can set multiple timeouts', function() { + let executor = new FakeExecutor() + .expect(CName.SET_TIMEOUT, {script:1, pageLoad: 2, implicit: 3}) + .andReturnSuccess() + .end(); + let driver = executor.createDriver(); + return driver.manage() + .setTimeouts({script: 1, pageLoad: 2, implicit: 3}); + }); + + it('falls back to legacy wire format if W3C version fails', () => { + let executor = new FakeExecutor() + .expect(CName.SET_TIMEOUT, {implicit: 3}) + .andReturnError(Error('oops')) + .expect(CName.SET_TIMEOUT, {type: 'implicit', ms: 3}) + .andReturnSuccess() + .end(); + let driver = executor.createDriver(); + return driver.manage().setTimeouts({implicit: 3}); + }); + + describe('deprecated API calls setTimeouts()', function() { + it('implicitlyWait()', function() { + let executor = new FakeExecutor() + .expect(CName.SET_TIMEOUT, {implicit: 3}) + .andReturnSuccess() + .end(); + let driver = executor.createDriver(); + return driver.manage().timeouts().implicitlyWait(3); + }); + + it('setScriptTimeout()', function() { + let executor = new FakeExecutor() + .expect(CName.SET_TIMEOUT, {script: 3}) + .andReturnSuccess() + .end(); + let driver = executor.createDriver(); + return driver.manage().timeouts().setScriptTimeout(3); + }); + + it('pageLoadTimeout()', function() { + let executor = new FakeExecutor() + .expect(CName.SET_TIMEOUT, {pageLoad: 3}) + .andReturnSuccess() + .end(); + let driver = executor.createDriver(); + return driver.manage().timeouts().pageLoadTimeout(3); + }); + }); + }); + }); + describe('generator support', function() { var driver; |