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

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

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!

Is it possible to animate extension popup opening?

I developed a simple chrome extension. Following the answers in this SO post I was able to programmatically open the popup window on certain webpages. The default behavior of the popup is to open a window at the top right. Is it possible to modify this behavior? Ideally, I would like the popup window to slide in from the right after the automatic window.open is invoked in the background script.
No, you have no control over how and where it appears.
If you want something like slide-in, you're better off injecting your GUI elements into the page itself.
How feasible it is depends on whether you need to inject it into an arbitrary page or if you're working with just one specific website. Shadow DOM might help you isolate styles from the parent page.

Handling Modal Dialog box from webpage in watir

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.

Does Selenium require maximized browser window?

I have not used Selenium myself, but I was wondering whether the browser window needs to be maximized during test execution? I have used some other tools where the mouse pointer does not find the correct HTML element if the window is too small.
Selenium 2.0 (WebDriver) automatically attempts to scroll an element into view when you're going to perform any action on this element. If it can't scroll it throws an exception. So, don't make your window too small, but there is no need to maximize it. Keep it "mid-size".
For the abovementioned reason, you may want to maximize the browser window to avoid excessive scrolling, that can cause some unnecesssary events on the page.
Sometimes Selenium (WebDriver) can't click an element if it is placed too close to the viewport border (half-visible). In this case you can try to tune the window size to make this element either totally visible, or totally invisible (to activate auto-scrolling).
If you use Selenium (WebDriver) with "native events" enabled, you'd better keep the browser window in foreground and in focus during test execution. No matter whether it is maximized or "mid-size" -- just don't minimize it!
If you're happy with "synthesized events" -- many chances for your tests to run successfully in foreground.
No, because Selenium uses the DOM Structure to act on and not the OS(mouse, windows and stuff). You can actually minimize your window during a test.
Maybe not maximized, but probably best to have test at set minimum and maximum size.
An idea would be to have selenium resize the window for you before it runs the tests... A quick search gave me this: https://makandracards.com/makandra/9773-how-to-start-selenium-browser-with-custom-window-size

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

Resources