File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
javascript/node/selenium-webdriver Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -339,6 +339,19 @@ class Builder {
339
339
getCapabilities ( ) {
340
340
return this . capabilities_
341
341
}
342
+
343
+ /**
344
+ * Sets the desired capability when requesting a new session.
345
+ * If there is already a capability named key, its value will be overwritten with value.
346
+ * This is a convenience wrapper around builder.getCapabilities().set(key, value) to support Builder method chaining.
347
+ * @param {string } key The capability key.
348
+ * @param {* } value The capability value.
349
+ * @return {!Builder } A self reference.
350
+ */
351
+ setCapability ( key , value ) {
352
+ this . capabilities_ . set ( key , value )
353
+ return this
354
+ }
342
355
343
356
/**
344
357
* Configures the target browser for clients created by this instance.
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ const safari = require('../safari')
27
27
const test = require ( '../lib/test' )
28
28
const { Browser } = require ( '../lib/capabilities' )
29
29
const { Pages } = require ( '../lib/test' )
30
+ const { Builder } = require ( '../../selenium-webdriver/index' )
30
31
31
32
test . suite ( function ( env ) {
32
33
const BROWSER_MAP = new Map ( [
@@ -68,6 +69,29 @@ test.suite(function (env) {
68
69
} )
69
70
} )
70
71
}
72
+
73
+ if ( BROWSER_MAP . has ( env . browser . name ) ) {
74
+ describe ( 'builder allows to set a single capability' , function ( ) {
75
+ let driver
76
+
77
+ after ( ( ) => driver && driver . quit ( ) )
78
+
79
+ it ( env . browser . name , async function ( ) {
80
+ let timeouts = { implicit : 0 , pageLoad : 1000 , script : 1000 }
81
+ driver = new Builder ( )
82
+ . setCapability ( 'timeouts' , timeouts )
83
+ . forBrowser ( env . browser . name )
84
+ . build ( )
85
+
86
+ let caps = await getCaps ( driver ) ;
87
+ assert . deepEqual ( caps . get ( 'timeouts' ) , timeouts )
88
+ } )
89
+ } )
90
+ }
91
+
92
+ async function getCaps ( driver ) {
93
+ return driver . getCapabilities ( ) ;
94
+ }
71
95
} )
72
96
73
97
describe ( 'Builder' , function ( ) {
You can’t perform that action at this time.
0 commit comments