HashNuke / hound

Elixir library for writing integration tests and browser automation
http://hexdocs.pm/hound
MIT License
1.36k stars 144 forks source link

Check if javascript alert is open #212

Open acrogenesis opened 6 years ago

acrogenesis commented 6 years ago

Can't find on the documentation a function to check if an alert is open, if I try to dismiss and it's not present it crashes

** (RuntimeError) no alert open
  (Session info: chrome=65.0.3325.181)
  (Driver info: chromedriver=2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef),platform=Mac OS X 10.13.4 x86_64)
    (hound) lib/hound/request_utils.ex:57: Hound.RequestUtils.handle_response/3
acrogenesis commented 6 years ago

This is what I came up with, but don't know if there's a better way.

try do
  accept_dialog()
rescue
  RuntimeError -> "Dialog not open"
end