Handling Modal Dialog box from webpage in watir - dialog

So I'm writing a watir-webdriver test script, and my webpage is using javascript:window.print to present a modal window that I want to interact with. When I click the link that presents the modal window, watir-webdriver just sits there until eventually it times out and i see a Timeout::Error on the console window. This is before attempting to interact with the new window at all. how do I tell it to move on without waiting?
After that whole execution is not responsive. Its not proceeding with next execution it gets struck there. tried the below solution too
element.focus element.send_keys :return
but no luck, Could anyone know how to resolve this modal dialogbox from webpage.
Thanks
get

I am using Firefox with Watir-webdriver.
browser.a:(:href => 'javascript:window.print()').click
this opens the Print dialog box. Which is the normal print dialog box from teh Firefox browser.
It just waits here and doesn't execute anything after that till i click manually or it timesout.

Related

How do you click a button in a browser popup window

I'm new to using Watir and have a problem. Within my browser page there is an option to add a note. This brings up a window within the browser which has the following id:
span id="ui-id-2" class="ui-dialog-title">Add Note</span
I can't work out how to use the controls within this window such as the 'Save' button as Watir doesn't seem to recognise either the window or the controls
So if I wanted to use same type of Save button within the main browser it would be fine; I'd just use browser.button(:id=> "Save").click.
Trying to use it within the popup though won't work as Watir can't recognise it within the popup. Any ideas appreciated!

How does Watir waits for page to load after selecting a value from list box?

Whenever a page load happens after selecting a value from list box or clicking a button, watir waits for the page to load. But in watir webdriver it doesn't wait in the case of list box selection. I used both watir and watir-webdriver against the same application.
Can anyone confirm this behavior? Any idea why it was there in watir but not in watir webdriver?
Update:
#browser.text_field(:id,"name").set("Sivaguru")
#browser.select_list(:id,"Gender").select("Male")
#browser.button(:id,"Submit").click
#browser.text_field(:id,"comments").set("sample")
In the above sample code, two times the page is loaded. one is after the selection and the other one is after click on the button.
In the case of watir , it by default waits for both the page loads. But watir webdriver waits in the case of button click but not on selection.
Since I am working on migrating from watir to webdriver i am interested to understand this behaviour before do changes to the existing code.
I cannot speak to Watir, but Watir-webdriver has plenty of methods available that would allow you wait until an element is present/visible before acting on it. I personally have not used watir, but my assumption based on your question would be that watir possibly takes care of the waiting for you, whereas watir-webdriver gives you more control but allowing you deliberate control over the waiting

chrome extension popup not open immediately

I'm writing a chrome extension.
When i click the browser action button in the first time - all goes well.
When i click the browser action button the second time, after several minutes of not clicking it, it takes more than 10 seconds until the popup is shown.
I've tried commenting out all of the periodic methods in the background and all of the methods in the load event of the popup, but it still doesn't shown immediately.
any suggestions?
I had a similar issue with the popup when I was adding an iframe to the popup. Chrome would wait with showing the popup until that iframe was loaded.
For me the fix was wrapping the code that added the iframe to the HTML in:
setTimeout(function(){
// Code here
},0);
This way Chrome showed the popup first, after which it begin with loading the iframe.
Maybe you have a similar problem?
i have seen this behavior before when you have a long running ajax call that you are doing on popup load.. hard to tell further without code samples or description of what you are doing

Yahoo UI the popup implementation with YAHOO.widget.Dialog

I used the Yahoo.widget.dialog to implement a popup window. Currently, it popups only on the page which is belongs. If I am working on the other (tab browser) pages. The popup window will be not seen.Could somebody supply some help for this ?Thanks
You could either switch to window.alert() or use window.open() to open a new pop-up window containing your content.
Neither one is something I'd personally want to experience, but those are your two options for opening a pop-up outside the page. Window.open will get caught by many pop-up blockers so you'll need to watch for that.

How is "Are you sure you want to navigate away from this page? " generated in browsers?

I have a page where I open a "modal window". It is really just a DIV, with an IFRAME inside, where I load another page. When I want to refresh the page, the browser pops up a window saying "Are you sure you want to navigate away from this page? Reloading this page will cause the modal window to disappear. Press OK to continue, or Cancel to stay on the current page."
How does this message get generated? How does the browser figure out that I have a modal window there, because I don't use any window.open() call from JavaScript? Is there any way to disable this behavior of the browser.
It may be body.onunload in the source of the page loaded in the IFRAME.
As the modal window is essentially an IFRAME, then when you close (or refresh) the main window, the browser knows it is killing that IFRAME, hence any body.onunload in that IFRAME fires.
If you have a function that handel onbeforeunload, automaticaly the Firefox message is generated.
you can disable it by returning null at the and of your handler.
This could be caused by some script modifying all off-site links to display this modal window, and then return true, or return false based upon your interaction with the modal window.
If you want to strip that behavior, you could remove all click events for external links.

Resources