Skip to content

Commit 91d26bb

Browse files
committed
Hide errors in buggy locator builders
1 parent 50039c6 commit 91d26bb

File tree

1 file changed

+41
-36
lines changed

1 file changed

+41
-36
lines changed

ide/main/src/content/locatorBuilders.js

+41-36
Original file line numberDiff line numberDiff line change
@@ -73,44 +73,49 @@ LocatorBuilders.prototype.buildAll = function(el) {
7373
for (var i = 0; i < LocatorBuilders.order.length; i++) {
7474
var finderName = LocatorBuilders.order[i];
7575
this.log.debug("trying " + finderName);
76-
locator = this.buildWith(finderName, e);
77-
if (locator) {
78-
locator = String(locator);
79-
this.log.debug("locator=" + locator);
80-
// test the locator. If a is_fuzzy_match() heuristic function is
81-
// defined for the location strategy, use it to determine the
82-
// validity of the locator's results. Otherwise, maintain existing
83-
// behavior.
84-
// try {
85-
// //alert(PageBot.prototype.locateElementByUIElement);
86-
// //Samit: The is_fuzzy_match stuff is buggy - comparing builder name with a locator name usually results in an exception :(
87-
// var is_fuzzy_match = this.pageBot().locationStrategies[finderName].is_fuzzy_match;
88-
// if (is_fuzzy_match) {
89-
// if (is_fuzzy_match(this.findElement(locator), e)) {
90-
// locators.push([ locator, finderName ]);
91-
// }
92-
// }
93-
// else {
94-
// if (e == this.findElement(locator)) {
95-
// locators.push([ locator, finderName ]);
96-
// }
97-
// }
98-
// }
99-
// catch (exception) {
100-
// if (e == this.findElement(locator)) {
101-
// locators.push([ locator, finderName ]);
102-
// }
103-
// }
104-
105-
//Samit: The following is a quickfix for above commented code to stop exceptions on almost every locator builder
106-
//TODO: the builderName should NOT be used as a strategy name, create a feature to allow locatorBuilders to specify this kind of behaviour
107-
//TODO: Useful if a builder wants to capture a different element like a parent. Use the this.elementEquals
108-
var fe = this.findElement(locator);
109-
if ((e == fe) || (coreLocatorStrategies[finderName] && coreLocatorStrategies[finderName].is_fuzzy_match && coreLocatorStrategies[finderName].is_fuzzy_match(fe, e))) {
110-
locators.push([ locator, finderName ]);
111-
}
76+
try {
77+
locator = this.buildWith(finderName, e);
78+
if (locator) {
79+
locator = String(locator);
80+
this.log.debug("locator=" + locator);
81+
// test the locator. If a is_fuzzy_match() heuristic function is
82+
// defined for the location strategy, use it to determine the
83+
// validity of the locator's results. Otherwise, maintain existing
84+
// behavior.
85+
// try {
86+
// //alert(PageBot.prototype.locateElementByUIElement);
87+
// //Samit: The is_fuzzy_match stuff is buggy - comparing builder name with a locator name usually results in an exception :(
88+
// var is_fuzzy_match = this.pageBot().locationStrategies[finderName].is_fuzzy_match;
89+
// if (is_fuzzy_match) {
90+
// if (is_fuzzy_match(this.findElement(locator), e)) {
91+
// locators.push([ locator, finderName ]);
92+
// }
93+
// }
94+
// else {
95+
// if (e == this.findElement(locator)) {
96+
// locators.push([ locator, finderName ]);
97+
// }
98+
// }
99+
// }
100+
// catch (exception) {
101+
// if (e == this.findElement(locator)) {
102+
// locators.push([ locator, finderName ]);
103+
// }
104+
// }
105+
106+
//Samit: The following is a quickfix for above commented code to stop exceptions on almost every locator builder
107+
//TODO: the builderName should NOT be used as a strategy name, create a feature to allow locatorBuilders to specify this kind of behaviour
108+
//TODO: Useful if a builder wants to capture a different element like a parent. Use the this.elementEquals
109+
var fe = this.findElement(locator);
110+
if ((e == fe) || (coreLocatorStrategies[finderName] && coreLocatorStrategies[finderName].is_fuzzy_match && coreLocatorStrategies[finderName].is_fuzzy_match(fe, e))) {
111+
locators.push([ locator, finderName ]);
112+
}
112113

113114

115+
}
116+
} catch (e) {
117+
// TODO ignore the buggy locator builder for now
118+
this.log.debug("locator exception: " + e);
114119
}
115120
}
116121
return locators;

0 commit comments

Comments
 (0)