Skip to content

Commit fa6deee

Browse files
committed
[JS] stop sending desiredCapabilities to local and remote end
1 parent 1c90777 commit fa6deee

File tree

2 files changed

+14
-241
lines changed

2 files changed

+14
-241
lines changed

javascript/node/selenium-webdriver/lib/webdriver.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class IWebDriver {
274274

275275
/**
276276
* @return {!Promise<!Capabilities>} A promise that will resolve with
277-
* the this instance's capabilities.
277+
* the instance's capabilities.
278278
*/
279279
getCapabilities() {}
280280

@@ -455,7 +455,7 @@ class IWebDriver {
455455
* @return {!(IThenable<T>|WebElementPromise)} A promise that will be
456456
* resolved with the first truthy value returned by the condition
457457
* function, or rejected if the condition times out. If the input
458-
* input condition is an instance of a {@link WebElementCondition},
458+
* condition is an instance of a {@link WebElementCondition},
459459
* the returned value will be a {@link WebElementPromise}.
460460
* @throws {TypeError} if the provided `condition` is not a valid type.
461461
* @template T
@@ -586,7 +586,7 @@ class IWebDriver {
586586
findElements(locator) {} // eslint-disable-line
587587

588588
/**
589-
* Takes a screenshot of the current page. The driver makes a best effort to
589+
* Takes a screenshot of the current page. The driver makes the best effort to
590590
* return a screenshot of the following, in order of preference:
591591
*
592592
* 1. Entire page
@@ -715,10 +715,9 @@ class WebDriver {
715715
static createSession(executor, capabilities, onQuit = undefined) {
716716
let cmd = new command.Command(command.Name.NEW_SESSION)
717717

718-
// For OSS remote ends.
719-
cmd.setParameter('desiredCapabilities', capabilities)
720718
// For W3C remote ends.
721719
cmd.setParameter('capabilities', {
720+
firstMatch: [{}],
722721
alwaysMatch: filterNonW3CCaps(capabilities),
723722
})
724723

@@ -1313,7 +1312,7 @@ class WebDriver {
13131312

13141313
/**
13151314
* Sets a listener for Fetch.authRequired event from CDP
1316-
* If event is triggered, it enter username and password
1315+
* If event is triggered, it enters username and password
13171316
* and allows the test to move forward
13181317
* @param {string} username
13191318
* @param {string} password
@@ -2060,7 +2059,7 @@ class Window {
20602059
}
20612060

20622061
/**
2063-
* Retrieves the a rect describing the current top-level window's size and
2062+
* Retrieves a rect describing the current top-level window's size and
20642063
* position.
20652064
*
20662065
* @return {!Promise<{x: number, y: number, width: number, height: number}>}
@@ -2540,7 +2539,7 @@ class WebElement {
25402539
}
25412540

25422541
/**
2543-
* Locates all of the descendants of this element that match the given search
2542+
* Locates all the descendants of this element that match the given search
25442543
* criteria.
25452544
*
25462545
* @param {!(by.By|Function)} locator The locator strategy to use when
@@ -3073,7 +3072,7 @@ class ShadowRoot {
30733072
}
30743073

30753074
/**
3076-
* Locates all of the descendants of this element that match the given search
3075+
* Locates all the descendants of this element that match the given search
30773076
* criteria.
30783077
*
30793078
* @param {!(by.By|Function)} locator The locator strategy to use when

javascript/node/selenium-webdriver/test/lib/webdriver_test.js

+6-232
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ describe('WebDriver', function () {
188188
let executor = new FakeExecutor()
189189
.expect(CName.NEW_SESSION)
190190
.withParameters({
191-
desiredCapabilities: { browserName: 'firefox' },
192191
capabilities: {
193192
alwaysMatch: { browserName: 'firefox' },
193+
firstMatch: [{}],
194194
},
195195
})
196196
.andReturnSuccess(aSession)
@@ -207,15 +207,12 @@ describe('WebDriver', function () {
207207
let executor = new FakeExecutor()
208208
.expect(CName.NEW_SESSION)
209209
.withParameters({
210-
desiredCapabilities: {
211-
'moz:debuggerAddress': true,
212-
browserName: 'firefox',
213-
},
214210
capabilities: {
215211
alwaysMatch: {
216212
'moz:debuggerAddress': true,
217213
browserName: 'firefox',
218214
},
215+
firstMatch: [{}],
219216
},
220217
})
221218
.andReturnSuccess(aSession)
@@ -230,9 +227,9 @@ describe('WebDriver', function () {
230227
let executor = new FakeExecutor()
231228
.expect(CName.NEW_SESSION)
232229
.withParameters({
233-
desiredCapabilities: { browserName: 'firefox', foo: 'bar' },
234230
capabilities: {
235-
alwaysMatch: { browserName: 'firefox' },
231+
alwaysMatch: { browserName: 'firefox'},
232+
firstMatch: [{}],
236233
},
237234
})
238235
.andReturnSuccess(aSession)
@@ -249,9 +246,9 @@ describe('WebDriver', function () {
249246
let executor = new FakeExecutor()
250247
.expect(CName.NEW_SESSION)
251248
.withParameters({
252-
desiredCapabilities: { browserName: 'firefox' },
253249
capabilities: {
254250
alwaysMatch: { browserName: 'firefox' },
251+
firstMatch: [{}],
255252
},
256253
})
257254
.andReturnError(new StubError())
@@ -268,9 +265,9 @@ describe('WebDriver', function () {
268265
let executor = new FakeExecutor()
269266
.expect(CName.NEW_SESSION)
270267
.withParameters({
271-
desiredCapabilities: { browserName: 'firefox' },
272268
capabilities: {
273269
alwaysMatch: { browserName: 'firefox' },
270+
firstMatch: [{}],
274271
},
275272
})
276273
.andReturnError(new StubError())
@@ -1728,227 +1725,4 @@ describe('WebDriver', function () {
17281725
})
17291726
})
17301727
})
1731-
1732-
describe('wire format', function () {
1733-
const FAKE_DRIVER = new FakeExecutor().createDriver()
1734-
1735-
describe('can serialize', function () {
1736-
function runSerializeTest(input, want) {
1737-
let executor = new FakeExecutor()
1738-
.expect(CName.NEW_SESSION)
1739-
.withParameters({
1740-
desiredCapabilities: { 'serialize-test': want },
1741-
capabilities: { alwaysMatch: {} },
1742-
})
1743-
.andReturnSuccess({ browserName: 'firefox' })
1744-
.end()
1745-
// We stuff the value to be serialized inside of a capabilities object,
1746-
// using a non-W3C key so that the value gets dropped from the W3C
1747-
// capabilities object.
1748-
return WebDriver.createSession(executor, {
1749-
'serialize-test': input,
1750-
}).getSession()
1751-
}
1752-
1753-
it('function as a string', function () {
1754-
function foo() {
1755-
return 'foo'
1756-
}
1757-
return runSerializeTest(foo, '' + foo)
1758-
})
1759-
1760-
it('object with toJSON()', function () {
1761-
return runSerializeTest(
1762-
new Date(605728511546),
1763-
'1989-03-12T17:55:11.546Z'
1764-
)
1765-
})
1766-
1767-
it('Session', function () {
1768-
return runSerializeTest(new Session('foo', {}), 'foo')
1769-
})
1770-
1771-
it('Capabilities', function () {
1772-
const prefs = new logging.Preferences()
1773-
prefs.setLevel(logging.Type.BROWSER, logging.Level.DEBUG)
1774-
1775-
const caps = Capabilities.chrome()
1776-
caps.setLoggingPrefs(prefs)
1777-
1778-
return runSerializeTest(caps, {
1779-
browserName: 'chrome',
1780-
'goog:loggingPrefs': { browser: 'DEBUG' },
1781-
})
1782-
})
1783-
1784-
it('WebElement', function () {
1785-
return runSerializeTest(
1786-
new WebElement(FAKE_DRIVER, 'fefifofum'),
1787-
WebElement.buildId('fefifofum')
1788-
)
1789-
})
1790-
1791-
it('WebElementPromise', function () {
1792-
return runSerializeTest(
1793-
new WebElementPromise(
1794-
FAKE_DRIVER,
1795-
Promise.resolve(new WebElement(FAKE_DRIVER, 'fefifofum'))
1796-
),
1797-
WebElement.buildId('fefifofum')
1798-
)
1799-
})
1800-
1801-
describe('an array', function () {
1802-
it('with Serializable', function () {
1803-
return runSerializeTest([new Session('foo', {})], ['foo'])
1804-
})
1805-
1806-
it('with WebElement', function () {
1807-
return runSerializeTest(
1808-
[new WebElement(FAKE_DRIVER, 'fefifofum')],
1809-
[WebElement.buildId('fefifofum')]
1810-
)
1811-
})
1812-
1813-
it('with WebElementPromise', function () {
1814-
return runSerializeTest(
1815-
[
1816-
new WebElementPromise(
1817-
FAKE_DRIVER,
1818-
Promise.resolve(new WebElement(FAKE_DRIVER, 'fefifofum'))
1819-
),
1820-
],
1821-
[WebElement.buildId('fefifofum')]
1822-
)
1823-
})
1824-
1825-
it('complex array', function () {
1826-
const expected = [
1827-
'abc',
1828-
123,
1829-
true,
1830-
WebElement.buildId('fefifofum'),
1831-
[123, { foo: 'bar' }],
1832-
]
1833-
1834-
const element = new WebElement(FAKE_DRIVER, 'fefifofum')
1835-
const input = ['abc', 123, true, element, [123, { foo: 'bar' }]]
1836-
return runSerializeTest(input, expected)
1837-
})
1838-
1839-
it('nested promises', function () {
1840-
return runSerializeTest(
1841-
['abc', Promise.resolve([123, Promise.resolve(true)])],
1842-
['abc', [123, true]]
1843-
)
1844-
})
1845-
})
1846-
1847-
describe('an object', function () {
1848-
it('literal', function () {
1849-
const expected = { sessionId: 'foo' }
1850-
return runSerializeTest({ sessionId: 'foo' }, expected)
1851-
})
1852-
1853-
it('with sub-objects', function () {
1854-
const expected = { sessionId: { value: 'foo' } }
1855-
return runSerializeTest({ sessionId: { value: 'foo' } }, expected)
1856-
})
1857-
1858-
it('with values that have toJSON', function () {
1859-
return runSerializeTest(
1860-
{ a: { b: new Date(605728511546) } },
1861-
{ a: { b: '1989-03-12T17:55:11.546Z' } }
1862-
)
1863-
})
1864-
1865-
it('with a Session', function () {
1866-
return runSerializeTest({ a: new Session('foo', {}) }, { a: 'foo' })
1867-
})
1868-
1869-
it('nested', function () {
1870-
const elementJson = WebElement.buildId('fefifofum')
1871-
const expected = {
1872-
script: 'return 1',
1873-
args: ['abc', 123, true, elementJson, [123, { foo: 'bar' }]],
1874-
sessionId: 'foo',
1875-
}
1876-
1877-
const element = new WebElement(FAKE_DRIVER, 'fefifofum')
1878-
const parameters = {
1879-
script: 'return 1',
1880-
args: ['abc', 123, true, element, [123, { foo: 'bar' }]],
1881-
sessionId: new Session('foo', {}),
1882-
}
1883-
1884-
return runSerializeTest(parameters, expected)
1885-
})
1886-
1887-
it('nested promises', function () {
1888-
const input = {
1889-
struct: Promise.resolve({
1890-
element: new WebElementPromise(
1891-
FAKE_DRIVER,
1892-
Promise.resolve(new WebElement(FAKE_DRIVER, 'fefifofum'))
1893-
),
1894-
}),
1895-
}
1896-
1897-
const want = {
1898-
struct: {
1899-
element: WebElement.buildId('fefifofum'),
1900-
},
1901-
}
1902-
1903-
return runSerializeTest(input, want)
1904-
})
1905-
})
1906-
})
1907-
1908-
describe('can deserialize', function () {
1909-
function runDeserializeTest(original, want) {
1910-
let executor = new FakeExecutor()
1911-
.expect(CName.GET_CURRENT_URL)
1912-
.andReturnSuccess(original)
1913-
.end()
1914-
let driver = executor.createDriver()
1915-
return driver.getCurrentUrl().then(function (got) {
1916-
assert.deepStrictEqual(got, want)
1917-
})
1918-
}
1919-
1920-
it('primitives', function () {
1921-
return Promise.all([
1922-
runDeserializeTest(1, 1),
1923-
runDeserializeTest('', ''),
1924-
runDeserializeTest(true, true),
1925-
runDeserializeTest(undefined, null),
1926-
runDeserializeTest(null, null),
1927-
])
1928-
})
1929-
1930-
it('simple object', function () {
1931-
return runDeserializeTest({ sessionId: 'foo' }, { sessionId: 'foo' })
1932-
})
1933-
1934-
it('nested object', function () {
1935-
return runDeserializeTest({ foo: { bar: 123 } }, { foo: { bar: 123 } })
1936-
})
1937-
1938-
it('array', function () {
1939-
return runDeserializeTest(
1940-
[{ foo: { bar: 123 } }],
1941-
[{ foo: { bar: 123 } }]
1942-
)
1943-
})
1944-
1945-
it('passes through function properties', function () {
1946-
function bar() {}
1947-
return runDeserializeTest(
1948-
[{ foo: { bar: 123 }, func: bar }],
1949-
[{ foo: { bar: 123 }, func: bar }]
1950-
)
1951-
})
1952-
})
1953-
})
19541728
})

0 commit comments

Comments
 (0)