Skip to content
This repository was archived by the owner on Jan 17, 2020. It is now read-only.

Refactored _exact and _find #23

Merged
merged 1 commit into from
Sep 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions src/Selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,11 @@ function _find(nothing) {
return function(driver) {
return function(by) {
return function(cb) {
driver.isElementPresent(by)
.then(function(is) {
if (is) {
var el = driver.findElement(by);
return cb(just(el));
} else {
return cb(nothing);
}
})
.thenCatch(function() {
return cb(nothing);
});

driver.findElement(by).then(function(el) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, I could see where the old version might go wrong... nice catch!

return cb(just(el));
}).thenCatch(function() {
return cb(nothing);
});
};
};
};
Expand All @@ -133,20 +125,7 @@ function _find(nothing) {
function _exact(driver) {
return function(by) {
return function(cb, eb) {
driver.isElementPresent(by)
.then(function(is) {
if (is) {
var el = driver.findElement(by);
return cb(el);
} else {
var error = "couldn't find element using locator " + by.toString();
return eb(new Error(error));
}
})
.thenCatch(function(e) {
return eb(e);
});

driver.findElement(by).then(cb).thenCatch(eb);
};
};
}
Expand Down