This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -953,6 +953,20 @@ ElementFinder.prototype.allowAnimations = function(value) {
953
953
return this . elementArrayFinder_ . allowAnimations ( value ) . toElementFinder_ ( ) ;
954
954
} ;
955
955
956
+
957
+ /**
958
+ * Compares an element to this one for equality.
959
+ *
960
+ * @param {!ElementFinder|!webdriver.WebElement } The element to compare to.
961
+ *
962
+ * @return {!webdriver.promise.Promise.<boolean> } A promise that will be
963
+ * resolved to whether the two WebElements are equal.
964
+ */
965
+ ElementFinder . prototype . equals = function ( element ) {
966
+ return webdriver . WebElement . equals ( this . getWebElement ( ) ,
967
+ element . getWebElement ? element . getWebElement ( ) : element ) ;
968
+ } ;
969
+
956
970
/**
957
971
* Shortcut for querying the document directly with css.
958
972
* `element(by.css('.abc'))` is equivalent to `$('.abc')`
Original file line number Diff line number Diff line change @@ -186,6 +186,16 @@ describe('ElementFinder', function() {
186
186
) . toEqual ( 'Anon' ) ;
187
187
188
188
} ) ;
189
+
190
+ it ( 'should check equality correctly' , function ( ) {
191
+ browser . get ( 'index.html#/form' ) ;
192
+
193
+ var usernameInput = element ( by . model ( 'username' ) ) ;
194
+ var name = element ( by . binding ( 'username' ) ) ;
195
+
196
+ expect ( usernameInput . equals ( usernameInput ) ) . toEqual ( true ) ;
197
+ expect ( usernameInput . equals ( name ) ) . toEqual ( false ) ;
198
+ } ) ;
189
199
} ) ;
190
200
191
201
describe ( 'ElementArrayFinder' , function ( ) {
You can’t perform that action at this time.
0 commit comments