How to ignore JS errors?
bapti opened this issue · 3 comments
Issue
I'm using chromedriver/wallaby to view a webpage but it's throwing back an error from javascript. I don't really care that the page is erroring, I just want to get the HTML back from the session.
** (Wallaby.JSError) There was an uncaught JavaScript error:
https://www.mysite.co.uk/site/wp-content/themes/mysite/js/functions.js?ver=20150330 179:25 Uncaught TypeError: $(...).countdown is not a function
(wallaby 0.29.1) lib/wallaby/chrome/logger.ex:8: Wallaby.Chrome.Logger.parse_log/1
(elixir 1.13.1) lib/enum.ex:937: Enum."-each/2-lists^foreach/1-0-"/2
(wallaby 0.29.1) lib/wallaby/driver/log_checker.ex:12: Wallaby.Driver.LogChecker.check_logs!/2
(wallaby 0.29.1) lib/wallaby/browser.ex:1232: Wallaby.Browser.visit/2
My Wallaby code is as follows, I've included js_errors: false
which I thought would ignore the errors
{:ok, session} =
Wallaby.start_session(
capabilities: %{
javascriptEnabled: true,
chromeOptions: %{args: ["--headless"]},
js_errors: false,
max_wait_time: 15_000
}
)
Any help would be much appreciated, thanks so much!
Details
Wallaby: 0.29.1
Elixir: 1.13.1
Erlang: OTP22
OS: Mac OSX
Webdriver: chromedriver
Browser: Chrome
Environment: Local
** (Wallaby.JSError) There was an uncaught JavaScript error: ....
** (Wallaby.JSError) There was an uncaught JavaScript error: ....
** (Wallaby.JSError) There was an uncaught JavaScript error: ....
I'm getting that all the time. I am trying to automate testing for a 3rd party which uses advertisement. The ad people frequently pull in stupid little JS bugs that blow up despite having set js_errors: false. The correct answer here might be Wallaby is a hammer and my problem is a screw. Nevertheless, I'd love to see wallaby able to handle Selenium nicer.
Am I not starting Wallaby correctly to ignore JS errors?
{:ok, session} = Wallaby.start_session(
js_errors: false, # Not working here
capabilities: %{
js_errors: false, # Not working here either
chromeOptions: %{
args: [..
I wouldn't call this a fix, but as a hack.
vi config/config.exs
# add
config :wallaby, js_errors: false
Fix would be allowing systems to start wallaby without having to rely on a config.
Hello all
To turn ignore JS errors, please use the config option that @blackham noted. I'm not sure why you would refer to that as a hack tho, as that is a valid configuration option.
It is not currently possible to control the configuration per session however.
You can see this documented here: https://hexdocs.pm/wallaby/Wallaby.html#module-configuration