I am submitting a form with selenium and phantomjs and then navigating back to the previous page by searching for a br element indicating that the form has been submitted. Occasionally the timeout will exceed the 30s allotted time and an error will occur:
TimeoutError: Waiting for element to be located By(xpath,//div[@id='ContactFormBody']/div/br)
Wait timed out after 30003ms
I need to handle this error so that my program will not crash if this occurs. Additionally if anyone wants to mention good documentation for selenium node.js, that would be great!
// code generating wait error
form.then(function(self){
driver.wait(until.elementLocated(By.xpath("//div[@id='ContactFormBody']/div/br")), 30000)
.then(function(){
driver.navigate().back();
});
});
// attempt at handling error
form.then(function(self){
try{
driver.wait(until.elementLocated(By.xpath("//div[@id='ContactFormBody']/div/br")), 30000)
.then(function(){
driver.navigate().back();
});
}
catch(e){
console.log("error occurred, script will continue.")
}
});
brthat would indicate the form submission..does not sound very reliable..is there any other form submission indication on the page? Thanks.bris a constant though its added in place of the form fields followed by text after form submission.