@@ -589,6 +589,23 @@ class IWebDriver {
589
589
}
590
590
591
591
592
+ /**
593
+ * @param {!Capabilities } capabilities A capabilities object.
594
+ * @return {!Capabilities } A copy of the parameter capabilities, omitting
595
+ * capability names that are not valid W3C names.
596
+ */
597
+ function filterNonW3CCaps ( capabilities ) {
598
+ let newCaps = new Capabilities ( capabilities ) ;
599
+ for ( let k of newCaps . keys ( ) ) {
600
+ // Any key containing a colon is a vendor-prefixed capability.
601
+ if ( ! ( W3C_CAPABILITY_NAMES . has ( k ) || k . indexOf ( ':' ) >= 0 ) ) {
602
+ newCaps . delete ( k ) ;
603
+ }
604
+ }
605
+ return newCaps ;
606
+ }
607
+
608
+
592
609
/**
593
610
* Each WebDriver instance provides automated control over a browser session.
594
611
*
@@ -625,23 +642,6 @@ class WebDriver {
625
642
/**
626
643
* Creates a new WebDriver session.
627
644
*
628
- * By default, the requested session `capabilities` are merely "desired" and
629
- * the remote end will still create a new session even if it cannot satisfy
630
- * all of the requested capabilities. You can query which capabilities a
631
- * session actually has using the
632
- * {@linkplain #getCapabilities() getCapabilities()} method on the returned
633
- * WebDriver instance.
634
- *
635
- * To define _required capabilities_, provide the `capabilities` as an object
636
- * literal with `required` and `desired` keys. The `desired` key may be
637
- * omitted if all capabilities are required, and vice versa. If the server
638
- * cannot create a session with all of the required capabilities, it will
639
- * return an {@linkplain error.SessionNotCreatedError}.
640
- *
641
- * let required = new Capabilities().set('browserName', 'firefox');
642
- * let desired = new Capabilities().set('version', '45');
643
- * let driver = WebDriver.createSession(executor, {required, desired});
644
- *
645
645
* This function will always return a WebDriver instance. If there is an error
646
646
* creating the session, such as the aforementioned SessionNotCreatedError,
647
647
* the driver will have a rejected {@linkplain #getSession session} promise.
@@ -657,10 +657,8 @@ class WebDriver {
657
657
*
658
658
* @param {!command.Executor } executor The executor to create the new session
659
659
* with.
660
- * @param {(!Capabilities|
661
- * {desired: (Capabilities|undefined),
662
- * required: (Capabilities|undefined)})} capabilities The desired
663
- * capabilities for the new session.
660
+ * @param {!Capabilities } capabilities The desired capabilities for the new
661
+ * session.
664
662
* @param {(function(this: void): ?)= } onQuit A callback to invoke when
665
663
* the newly created session is terminated. This should be used to clean
666
664
* up any resources associated with the session.
@@ -669,24 +667,12 @@ class WebDriver {
669
667
static createSession ( executor , capabilities , onQuit = undefined ) {
670
668
let cmd = new command . Command ( command . Name . NEW_SESSION ) ;
671
669
672
- if ( capabilities && ( capabilities . desired || capabilities . required ) ) {
673
- // For OSS remote ends.
674
- cmd . setParameter ( 'desiredCapabilities' , capabilities . desired ) ;
675
- cmd . setParameter ( 'requiredCapabilities' , capabilities . required ) ;
676
- // For W3C remote ends.
677
- let merged = new Capabilities ( capabilities . desired ) ;
678
- merged . merge ( capabilities . required ) ;
679
- cmd . setParameter ( 'capabilities' , {
680
- alwaysMatch : WebDriver . filterNonW3CCaps_ ( merged ) ,
681
- } ) ;
682
- } else {
683
- // For OSS remote ends.
684
- cmd . setParameter ( 'desiredCapabilities' , capabilities ) ;
685
- // For W3C remote ends.
686
- cmd . setParameter ( 'capabilities' , {
687
- alwaysMatch : WebDriver . filterNonW3CCaps_ ( capabilities ) ,
688
- } ) ;
689
- }
670
+ // For OSS remote ends.
671
+ cmd . setParameter ( 'desiredCapabilities' , capabilities ) ;
672
+ // For W3C remote ends.
673
+ cmd . setParameter ( 'capabilities' , {
674
+ alwaysMatch : filterNonW3CCaps ( capabilities ) ,
675
+ } ) ;
690
676
691
677
let session = executeCommand ( executor , cmd ) ;
692
678
if ( typeof onQuit === 'function' ) {
@@ -697,23 +683,6 @@ class WebDriver {
697
683
return new this ( session , executor , onQuit ) ;
698
684
}
699
685
700
- /**
701
- * @param {!Capabilities } capabilities A capabilities object.
702
- * @return {!Capabilities } A copy of the parameter capabilities, omitting
703
- * capability names that are not valid W3C names.
704
- * @private
705
- */
706
- static filterNonW3CCaps_ ( capabilities ) {
707
- let newCaps = new Capabilities ( capabilities ) ;
708
- for ( let k of newCaps . keys ( ) ) {
709
- // Any key containing a colon is a vendor-prefixed capability.
710
- if ( ! ( W3C_CAPABILITY_NAMES . has ( k ) || k . indexOf ( ':' ) >= 0 ) ) {
711
- newCaps . delete ( k ) ;
712
- }
713
- }
714
- return newCaps ;
715
- }
716
-
717
686
/** @override */
718
687
async execute ( command ) {
719
688
command . setParameter ( 'sessionId' , this . session_ ) ;
0 commit comments