cucumber - How do you automatically confirm a modal in ruby using page-object? -


i have standard rails application delete link. delete link comes browser popup modal (using rails confirm option).

i attempting test delete function cucumber, selenium-webdriver (or watir-webdriver, still haven't decided), , page-object gem.

once modal has been triggered, on page gives me following error:

modal dialog present (selenium::webdriver::error::unhandledalerterror) 

i have been looking over, cannot find way handle condition. if possible, continue using pagefactory module in page-object gem.

how can dismiss/accept modal?

i figured out way this, haven't decided upon exact implementation.

in javascript can overwrite function, means can overwrite confirm

this means can run following code disable popups.

def disable_popups   # don't return alert   browser.execute_script("window.alert = function() {}")    # return string prompt simulate user entering   browser.execute_script("window.prompt = function() {return 'my name'}")    # return null prompt simulate clicking cancel   browser.execute_script("window.prompt = function() {return null}")    # return true confirm simulate clicking ok   browser.execute_script("window.confirm = function() {return true}")    # return false confirm simulate clicking cancel   browser.execute_script("window.confirm = function() {return false}") end 

if put inside initalize_page function of page-object dialogs automatically removed.

def initialize_page     disable_popups end 

or right before pop triggered

def delete   disable_popups   delete_link # => clicks link end 

references:


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -