-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect javascript errors when visiting a new web page #185
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,10 @@ public function visit($url) | |
} | ||
}); | ||
JS; | ||
$this->server->evalJS($js); | ||
$out = $this->server->evalJS($js); | ||
if (!empty($out)) { | ||
throw new DriverException(sprintf('Error when loading page %s: %s', $url, $out)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The right fix would rather be to prefix the error output with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then you will not get the same degree of specialized error message. You will get a more general error message, and you will not readily see the url that it tried to visit. You can also see that the same coding pattern is applied to the click function at line 719, and also in triggerBrowserEvent at line 890 |
||
} | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aik099 visiting a URL in Selenium uses a native Selenium method. So we don't need to implement error handling (Selenium does).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aik099 see the JS code just above. On error, it outputs some stuff to the stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The zombie "browser" object's method "visit" has a callback as its second argument that will be called if an error occurs. Currently this error information is just thrown away. I found it very helpful to have this error information in my project when making behat tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof has been quiet on this. I guess it is ok as it is then?