Detect errors on a page loaded using Page.goto - playwright

I would typically report a failed test when any of the following errors are reported after loading a page:
missing resources (javascript, stylesheet, ...)
any javascript exceptions
any console.error
I was wondering how to detect "errors" on a page that has been loaded using Page.goto in Playwright?

You will need to attach to some events and evaluate the incoming data:
Missing resources: Attach to the response event and check the response.status() value.
Javascript exceptions: Attach to the pageerror event.
Console error: Attach to the console event and filter messages where type() is error.

Related

Vaadin 23 TypeError: error loading dynamically imported module

In Firefox browser, not always (but very often) I see the following error in the console (and page is unable to load):
TypeError: error loading dynamically imported module
Only after Ctrl + F5 the page is loaded correctly.
Also in the Network tab I may see the following:
Uncaught (in promise) TypeError: error loading dynamically imported module router.js:525:10
ready router.js:525
(Async: promise callback)
render router.js:517
__onNavigationEvent router.js:932
setRoutes router.js:419
index.ts:32
There is no any other information. In Chrome, everything works fine. What may be the reason of this issue?
I noticed this after upgrade to Vaadin 23.2.1
Also, from time to time I have the following error:

For what reason can an error occur periodically in the client-side?

I have a Rails application that has several components written in Vue. All components are included in the "pack" file.
These two errors occur periodically in the browser (Safari):
SyntaxError: Unexpected token '|'
TypeError: Object(i.a) is not a function. (In 'Object(i.a)()', 'Object(i.a)' is an instance of Object)
The first error points to this line:
<meta name="csrf-token" content="qRbwC3xngly9Y5hRVLA86upHTEkVwIk10PiOtDWCw00RUkIhGK8UvEIhtUXebkzWaqlxsHPSBaheR1moaY-b9w"/>
I don't understand what the second line points to. The error refers to some function "c" in "node.js:15".
Clicking on it jumps to the comment:
In general, I do not understand what it is.
If reload the page, then everything will be fine. Well, that is the problem occurs randomly.
On the Sentry side, I get nothing. Apparently, this does not reach Sentry, the error is not caught and is not transmitted to Sentry.

Internal server error in loadrunner script while replay

I've recorded a workflow using proxy recorder for a mobile application which is using API calls in VUGEN(loadrunner 12.55). I am getting internal server error 500 during update (POST) function. Following is the code snippet of script generated by Loadrunner
web_submit_data("signin",
"Action=http://beautymarksapp.com/api/user/signin",
"Method=POST",
"RecContentType=application/json",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
"EncodeAtSign=YES",
ITEMDATA,
"Name=email", "Value=user#domain.com", ENDITEM,
"Name=password", "Value=BMARKS", ENDITEM,
"Name=timezone", "Value=18000", ENDITEM,
LAST);
web_custom_request("update",
"URL=http://beautymarksapp.com/api/user/update",
"Method=PUT",
"Resource=0",
"RecContentType=application/json",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
"Body=device_token=c7ff93995d1dea60fea773819b582235b6367c0c7275238a65c2035c2d96fde6&device_type=ios",
LAST);
Any help in this regard will be highly appreciated.
The most common answer for 500 are:
Unhandled Dynamic Item
No checking for expected results
No exception handling/branching when unexpected results appear

Handle Solr error messages from Blacklight

Whenever Solr fails executing a query for some reason it returns an error message and an error code. I would like to handle such errors in Blacklight. Right now, when receiving an error from Solr, the user gets a 500 internal error. As a developer I can see that what happens is an RSolr::Error::Http in CatalogController#index with the following line of code as the source of the problem:
res = blacklight_solr.send_and_receive(path, :params=>solr_params)
Is it possible to customize the error handling so that I can at least display an indicative error message to the user instead of the unhelpful 500 internal error?
Open file lib\blacklight\catalog.rb. The function rsolr_request_error(exception) is responsible to handle Solr errors. The exception parameter is an RSolr::RequestError and it represents the error from Solr. In order to handle the error by displaying the message from Solr just add the following inside the else:
error_status = eval(exception.response[:body])['error']
if !error_status.nil? and !error_status['msg'].nil?
flash_notice = error_status['msg']
else
flash_notice = I18n.t('blacklight.search.errors.request_error')
end
If you wish to display a different message then assign a different message to flash_notice. If you wish to handle the error differently then this is where to do so.

Console error with example of ui.bootstrap.datepicker

I try to use angular-ui-bootstrap datepicker and it upset me for a while with an error on firebug console (Firefox 21) saying
Error: array is undefined
indexOf#http://localhost:9000/components/angular/angular.js:526
arrayRemove#http://localhost:9000/components/angular/angular.js:535
JQLiteUnbind#http://localhost:9000/components/angular/angular.js:1630
JQLite.prototype[name]#http://localhost:9000/components/angular/angular.js:2203
.link/<#http://localhost:9000/components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.min.js:1
Scope.prototype.$digest#http://localhost:9000/components/angular/angular.js:7942
Scope.prototype.$apply#http://localhost:9000/components/angular/angular.js:8143
done#http://localhost:9000/components/angular/angular.js:9170
completeRequest#http://localhost:9000/components/angular/angular.js:9333
createHttpBackend/</xhr.onreadystatechange#http://localhost:9000/components/angular/angular.js:9304
http://localhost:9000/components/angular/angular.js
Line 5754
After I check every datepicker settings I check the given example in documentation, followed the link "edit it on plunker" and I got a similar error.
Error: array is undefined
indexOf#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:510
arrayRemove#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:519
JQLiteUnbind#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:1596
JQLite.prototype[name]#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:2149
.link/<#http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.5.0.js:1229
Scope.prototype.$digest#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:7878
Scope.prototype.$apply#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:8079
bootstrap/<#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:962
invoke#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:2843
bootstrap#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:961
angularInit#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:936
#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:14729
trigger#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:1723
createEventHandler/eventHandler/<#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:1958
forEach#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:133
createEventHandler/eventHandler#http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:1957
http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js
Line 5687
Then I try Chrome Version 26.0.1410.63 and I got a different error
TypeError: Cannot read property 'indexOf' of undefined
at indexOf (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:510:12)
at arrayRemove (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:519:15)
at JQLiteUnbind (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:1596:7)
at Object.JQLite.(anonymous function) [as unbind] (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:2149:17)
at Object.fn (http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.5.0.js:1229:21)
at Object.Scope.$digest (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:7878:27)
at Object.Scope.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:8079:24)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:962:13
at Object.invoke (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:2843:25)
at bootstrap (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js:960:12)
It works but the error message upset me a lot and I thought that was something wrong with my code.
Can I assume this is not related with example given but with some internals or is the example missing something?
ui-bootstrap 0.5.0 has a bug,
(it tries to unbind 'focus' event handler, but handler doesn't exist)
https://github.com/angular-ui/bootstrap/blob/gh-pages/ui-bootstrap-tpls-0.5.0.js#L1226
you can apply this changes
https://github.com/angular-ui/bootstrap/commit/bf30898da27272df75f6c7ff26545ed16ebf1978
or build it directly from github
or wait for 0.6.0

Resources