Last active
April 8, 2017 07:10
-
-
Save masonmark/d4dd2ae124003caedd97a89a65e054bd to your computer and use it in GitHub Desktop.
chromedriver bug workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clickElementById(id, timesTriedAlready) { | |
// var elem = element(by.id(id)); | |
// elem.click(); | |
// TRY: https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/2766#issuecomment-191963206 | |
// Mason 2017-04-08 | |
var elem = element(by.id(id)); | |
var maxIterations = 10; | |
var iterationCount = timesTriedAlready || 0; | |
var successFunc = function () { | |
console.log('w00t w00t clickElementById() succeeded.'); | |
}; | |
var failureFunc = function (err) { | |
iterationCount++; | |
console.log('ALERTALERTALERT clickElementById() failed:', err); | |
if (iterationCount < maxIterations) { | |
console.log("...recursively re-invoking click..."); | |
browser.sleep(1000); | |
clickElementById(id, iterationCount); | |
} else { | |
console.log('ALERTALERTALERT FAILFAILFAIL clickElementById() failed PERMANENTLY due to exceeding max iterations:', maxIterations, err); | |
} | |
}; | |
elem.click().then(successFunc, failureFunc); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment