1616
1717import { MozillaBrowserBot } from "./selenium-browserbot" ;
1818import { core } from "./closure-polyfill" ;
19- const exactMatchPattern = window . global . exactMatchPattern ;
19+ import { exactMatchPattern } from "./targetSelector" ;
2020
2121export default function LocatorBuilders ( window ) {
2222 this . window = window ;
@@ -290,11 +290,6 @@ LocatorBuilders.prototype.preciseXPath = function(xpath, e) {
290290 * ===== builders =====
291291 */
292292
293- LocatorBuilders . add ( "ui" , function ( pageElement ) {
294- return UIMap . getInstance ( ) . getUISpecifierString ( pageElement ,
295- this . window . document ) ;
296- } ) ;
297-
298293LocatorBuilders . add ( "id" , function ( e ) {
299294 if ( e . id ) {
300295 return "id=" + e . id ;
@@ -329,58 +324,6 @@ LocatorBuilders.add("css", function(e) {
329324 return "css=" + sub_path ;
330325} ) ;
331326
332- /*
333- * This function is called from DOM locatorBuilders
334- */
335- LocatorBuilders . prototype . findDomFormLocator = function ( form ) {
336- if ( form . hasAttribute ( "name" ) ) {
337- let name = form . getAttribute ( "name" ) ;
338- let locator = "document." + name ;
339- if ( this . findElement ( locator ) == form ) {
340- return locator ;
341- }
342- locator = "document.forms['" + name + "']" ;
343- if ( this . findElement ( locator ) == form ) {
344- return locator ;
345- }
346- }
347- let forms = this . window . document . forms ;
348- for ( let i = 0 ; i < forms . length ; i ++ ) {
349- if ( form == forms [ i ] ) {
350- return "document.forms[" + i + "]" ;
351- }
352- }
353- return null ;
354- } ;
355-
356- LocatorBuilders . add ( "dom:name" , function ( e ) {
357- if ( e . form && e . name ) {
358- let formLocator = this . findDomFormLocator ( e . form ) ;
359- if ( formLocator ) {
360- let candidates = [ formLocator + "." + e . name ,
361- formLocator + ".elements['" + e . name + "']"
362- ] ;
363- for ( let c = 0 ; c < candidates . length ; c ++ ) {
364- let locator = candidates [ c ] ;
365- let found = this . findElement ( locator ) ;
366- if ( found ) {
367- if ( found == e ) {
368- return locator ;
369- } else if ( found instanceof NodeList ) {
370- // multiple elements with same name
371- for ( let i = 0 ; i < found . length ; i ++ ) {
372- if ( found [ i ] == e ) {
373- return locator + "[" + i + "]" ;
374- }
375- }
376- }
377- }
378- }
379- }
380- }
381- return null ;
382- } ) ;
383-
384327LocatorBuilders . add ( "xpath:link" , function ( e ) {
385328 if ( e . nodeName == "A" ) {
386329 let text = e . textContent ;
@@ -477,21 +420,6 @@ LocatorBuilders.add("xpath:href", function(e) {
477420 return null ;
478421} ) ;
479422
480- LocatorBuilders . add ( "dom:index" , function ( e ) {
481- if ( e . form ) {
482- let formLocator = this . findDomFormLocator ( e . form ) ;
483- if ( formLocator ) {
484- let elements = e . form . elements ;
485- for ( let i = 0 ; i < elements . length ; i ++ ) {
486- if ( elements [ i ] == e ) {
487- return formLocator + ".elements[" + i + "]" ;
488- }
489- }
490- }
491- }
492- return null ;
493- } ) ;
494-
495423LocatorBuilders . add ( "xpath:position" , function ( e , opt_contextNode ) {
496424 //this.log.debug("positionXPath: e=" + e);
497425 let path = "" ;
@@ -515,4 +443,4 @@ LocatorBuilders.add("xpath:position", function(e, opt_contextNode) {
515443} ) ;
516444// Samit: Warning: The old method of setting the order using LocatorBuilders.order is now deprecated
517445// You can change the priority of builders by setting LocatorBuilders.order.
518- //LocatorBuilders.order = ['ui', ' id', 'link', 'name', 'css', 'dom:name', ' xpath:link', 'xpath:img', 'xpath:attributes', 'xpath:idRelative', 'xpath:href', 'dom:index ', 'xpath:position'];
446+ //LocatorBuilders.order = ['id', 'link', 'name', 'css', 'xpath:link', 'xpath:img', 'xpath:attributes', 'xpath:idRelative', 'xpath:href', 'xpath:position'];
0 commit comments