This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 3 files changed +29
-5
lines changed
3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -377,7 +377,7 @@ var buildElementHelper = function(ptor) {
377
377
}
378
378
this . locator_ = locator ;
379
379
this . parentElementFinder_ = opt_parentElementFinder || null ;
380
- this . actionResult_ = opt_actionResult || webdriver . promise . fulfilled ( null ) ;
380
+ this . opt_actionResult_ = opt_actionResult ;
381
381
this . opt_index_ = opt_index ;
382
382
383
383
var self = this ;
@@ -637,9 +637,13 @@ var buildElementHelper = function(ptor) {
637
637
* evaluating fn.
638
638
*/
639
639
ElementFinder . prototype . then = function ( fn ) {
640
- return this . actionResult_ . then ( function ( ) {
641
- return fn . apply ( null , arguments ) ;
642
- } ) ;
640
+ if ( this . opt_actionResult_ ) {
641
+ return this . opt_actionResult_ . then ( function ( ) {
642
+ return fn . apply ( null , arguments ) ;
643
+ } ) ;
644
+ } else {
645
+ return fn ( this ) ;
646
+ }
643
647
} ;
644
648
645
649
var element = function ( locator ) {
Original file line number Diff line number Diff line change 15
15
"request" : " ~2.36.0" ,
16
16
"selenium-webdriver" : " 2.42.0" ,
17
17
"minijasminenode" : " 0.4.0" ,
18
- "jasminewd" : " 1.0.0 " ,
18
+ "jasminewd" : " 1.0.1 " ,
19
19
"saucelabs" : " ~0.1.0" ,
20
20
"glob" : " ~3.2" ,
21
21
"adm-zip" : " 0.4.4" ,
Original file line number Diff line number Diff line change @@ -10,6 +10,26 @@ describe('locators', function() {
10
10
expect ( greeting . getText ( ) ) . toEqual ( 'Hiya' ) ;
11
11
} ) ;
12
12
13
+ it ( 'should allow custom expectations to expect an element' , function ( ) {
14
+ this . addMatchers ( {
15
+ toHaveText : function ( actualText ) {
16
+ return this . actual . getText ( ) . then ( function ( expectedText ) {
17
+ return expectedText === actualText ;
18
+ } ) ;
19
+ }
20
+ } ) ;
21
+
22
+ expect ( element ( by . binding ( '{{greeting}}' ) ) ) . toHaveText ( 'Hiya' ) ;
23
+ } ) ;
24
+
25
+ it ( 'ElementFinder.then should resolve to itself' , function ( ) {
26
+ var elem = element ( by . binding ( '{{greeting}}' ) ) ;
27
+
28
+ elem . then ( function ( elem2 ) {
29
+ expect ( elem ) . toEqual ( elem2 ) ;
30
+ } ) ;
31
+ } ) ;
32
+
13
33
it ( 'should find a binding by partial match' , function ( ) {
14
34
var greeting = element ( by . binding ( 'greet' ) ) ;
15
35
You can’t perform that action at this time.
0 commit comments