This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 4 files changed +58
-8
lines changed
4 files changed +58
-8
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ var util = require('util'),
8
8
webdriver = require ( 'selenium-webdriver' ) ,
9
9
q = require ( 'q' ) ;
10
10
11
-
12
11
var HostedDriverProvider = function ( config ) {
13
12
this . config_ = config ;
14
13
this . driver_ = null ;
@@ -21,8 +20,18 @@ var HostedDriverProvider = function(config) {
21
20
* ready to test.
22
21
*/
23
22
HostedDriverProvider . prototype . setupEnv = function ( ) {
24
- util . puts ( 'Using the selenium server at ' + this . config_ . seleniumAddress ) ;
25
- return q . fcall ( function ( ) { } ) ;
23
+ var config = this . config_ ,
24
+ seleniumAddress = config . seleniumAddress ;
25
+
26
+ if ( q . isPromiseAlike ( seleniumAddress ) ) {
27
+ return q . when ( seleniumAddress ) . then ( function ( resolvedAddress ) {
28
+ config . seleniumAddress = resolvedAddress ;
29
+ util . puts ( 'Using the selenium server at ' + config . seleniumAddress ) ;
30
+ } ) ;
31
+ } else {
32
+ util . puts ( 'Using the selenium server at ' + this . config_ . seleniumAddress ) ;
33
+ return q . fcall ( function ( ) { } ) ;
34
+ }
26
35
} ;
27
36
28
37
/**
Original file line number Diff line number Diff line change @@ -232,12 +232,17 @@ Runner.prototype.run = function() {
232
232
233
233
// 1) Setup environment
234
234
return this . driverprovider_ . setupEnv ( ) . then ( function ( ) {
235
- driver = self . driverprovider_ . getDriver ( ) ;
236
- return q . fcall ( function ( ) { } ) ;
235
+ return q . all (
236
+ [ self . config_ . capabilities , self . config_ . multiCapabilities ] ) .
237
+ spread ( function ( capabilites , multiCapabilities ) {
238
+ self . config_ . capabilities = capabilites ;
239
+ self . config_ . multiCapabilities = multiCapabilities ;
240
+ } ) . then ( function ( ) {
241
+ driver = self . driverprovider_ . getDriver ( ) ;
242
+ } ) ;
237
243
238
244
// 2) Execute test cases
239
245
} ) . then ( function ( ) {
240
-
241
246
var deferred = q . defer ( ) ;
242
247
driver . manage ( ) . timeouts ( ) . setScriptTimeout ( self . config_ . allScriptsTimeout ) ;
243
248
self . setupGlobals_ . bind ( self ) ( driver ) ;
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ testDriverProvider(require('../lib/driverProviders/chrome')(chromeConfig)).
52
52
} ) ;
53
53
54
54
var hostedConfig = {
55
- sauceAddress : 'http://localhost:4444/wd/hub' ,
55
+ seleniumAddress : 'http://localhost:4444/wd/hub' ,
56
56
capabilities : {
57
57
browserName : 'firefox'
58
58
}
@@ -64,6 +64,19 @@ testDriverProvider(require('../lib/driverProviders/hosted')(hostedConfig)).
64
64
console . log ( 'hosted.dp failed with ' + err ) ;
65
65
} ) ;
66
66
67
+ var hostedPromisedConfig = {
68
+ seleniumAddress : q . when ( 'http://localhost:4444/wd/hub' ) ,
69
+ capabilities : {
70
+ browserName : 'firefox'
71
+ }
72
+ } ;
73
+ testDriverProvider ( require ( '../lib/driverProviders/hosted' ) ( hostedPromisedConfig ) ) .
74
+ then ( function ( ) {
75
+ console . log ( 'hosted.dp with promises working!' ) ;
76
+ } , function ( err ) {
77
+ console . log ( 'hosted.dp with promises failed with ' + err ) ;
78
+ } ) ;
79
+
67
80
var localConfig = {
68
81
seleniumArgs : [ ] ,
69
82
capabilities : {
Original file line number Diff line number Diff line change @@ -30,11 +30,34 @@ describe('the Protractor runner', function() {
30
30
} ) ;
31
31
} ) ;
32
32
33
+ it ( 'should wait for promise capabilities to resolve' , function ( done ) {
34
+ var config = {
35
+ mockSelenium : true ,
36
+ specs : [ '*.js' ] ,
37
+ framework : 'debugprint' ,
38
+ capabilities : q . when ( {
39
+ 'browserName' : 'customfortest'
40
+ } )
41
+ } ;
42
+ var exitCode ;
43
+ Runner . prototype . exit_ = function ( exit ) {
44
+ exitCode = exit ;
45
+ } ;
46
+ var runner = new Runner ( config ) ;
47
+
48
+ runner . run ( ) . then ( function ( ) {
49
+ expect ( runner . getConfig ( ) . capabilities . browserName ) .
50
+ toEqual ( 'customfortest' ) ;
51
+ expect ( exitCode ) . toEqual ( 0 ) ;
52
+ done ( ) ;
53
+ } ) ;
54
+ } ) ;
55
+
33
56
it ( 'should fail with no specs' , function ( ) {
34
57
var config = {
35
58
mockSelenium : true ,
36
59
specs : [ ] ,
37
- framework : 'simpleprint '
60
+ framework : 'debugprint '
38
61
} ;
39
62
var exitCode ;
40
63
Runner . prototype . exit_ = function ( exit ) {
You can’t perform that action at this time.
0 commit comments