Random pop up appears and execution stops(WATIR tool)

Hi,

While I am navigating the pages using Watir tool, Ramdomly some pop up
appears like ‘system is taking care of some request, please wait for
some time’.Once this pop up comes, entire execution stops. The problem
here is, If I know the place where pop would appear I would able to
handle using pop up handler, But this pop is appearing randomly. I think
attachment is goes to that pop up, So it couldn’t continue. How would I
resolve this problem.

Normally I’d say deal with the underlying issue. If there’s an alert
like that then you should stop the test as a failure.

Otherwise:
My approach (in watir-webdriver) was to modify alert.rb to retry
detection several times, allowing for this kind of usage in places where
alerts might or might not appear:

alert.close if alert.exists?(2)

Part of alert.rb:


def exists?(timer=1)
  assert_exists(timer)
  true
rescue Exception::UnknownObjectException
  false
end

Another part of alert.rb:


def assert_exists(timer=1)
  @alert = @target_locator.alert
rescue Selenium::WebDriver::Error::NoAlertPresentError
  if @counter >= timer then
    raise Exception::UnknownObjectException, 'unable to locate 

alert’
else
@counter += 1
sleep 0.5
retry
end
end


This is code I wrote a long time ago, so I would probably do it
differently now. Still, it might give you some inspiration.

hi, That’s a good idea, but what is this alert? this alert is
javascript? In my case, My pop up is the part of the screen. And also I
am not using watir webdriver in my program, I am using Watir though.

If the “popup” is a hidden div, then you’ll need to check whether the
div is present and act accordingly. If it’s a JavaScript alert, then my
previous answer should help you

Ok, If it is the hidden div, How would I write the code as you have
written for alert? Is it possible?

If it is a div, then it’s probably modal, and will need to be handled in
a different way from the alert.

You would have to find an id or name for the div and then check whether
it is present at each point where it may appear. However, you cannot
simply “close” a div. You need to deal with it via whatever approach you
would use manually.
Retry the URL, click a button in the div… whatever it is you do
without Watir.

You still need to determine what the popup actually is, JS or HTML.
Do you get an Exception? An unhandled Exception would cause the program
to terminate.

NO, I am handling the exception, But each and every time program has to
start from first page.since it stops at the middle other testcase can’t
continue further.

Then you should use IRB and enter the test sequence manually, line by
line, in order to find out what you can do about it when the pop-up
appears.

hi

My problem is bit different than you explained, The pop up remain for
few seconds and it automatically closes. Once it pop up has been
closed,execution stops. So My problem is not to close the pop up but
continue the execution.

Ok Thank you.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs