Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/hound/helpers/dialog.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ defmodule Hound.Helpers.Dialog do

import Hound.RequestUtils

@doc """
Checks if a dialog, javascript alert(), confirm() or prompt(), exists

dialog_present?()
"""
@spec dialog_present?() :: Boolean.t
def dialog_present? do
try do
dialog_text()
true
rescue
RuntimeError -> false
end
end

@doc """
Gets text of a javascript alert(), confirm() or prompt().

Expand Down
6 changes: 6 additions & 0 deletions test/helpers/dialog_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ defmodule DialogTest do

hound_session()

test "Dialog present" do
navigate_to "http://localhost:9090/page1.html"
execute_script("alert('hello')")
assert dialog_present?() == true
end

test "Get dialog text" do
navigate_to "http://localhost:9090/page1.html"
execute_script("alert('hello')")
Expand Down