How do I test modal dialogs with Selenium? - unit-testing

I'm getting started with Selenium IDE and trying to test a webapp that's full of modal dialogs (window.showModalDialog).
Recording the test seems to work (except there's nothing in the log when the dialog pops up) but they don't play back properly. The script actually opens the window (triggered by a button click), but then just waits indefinitely.
Any suggestions?

From the Selenium FAQ, Selenium apparently works with some types of dialogs but not others:
I can't interact with a popup dialog.
My test stops in its tracks!
You can, but only if the dialog is an
alert or confirmation dialog. Other
special dialogs can't be dismissed by
javascript, and thus currently cannot
be interacted with. These include the
"Save File", "Remember this Password"
(Firefox), and modal (IE) dialogs.
When they appear, Selenium can only
wring its hands in despair.
To solve this issue, you may use a
workaround (if one exists); otherwise
you may have to exclude the test from
your automated corpus. For the "Save
File" dialog in Firefox, a custom
template may be specified when running
via the RC that will always cause the
file to be downloaded to a specified
location, without querying the user
(see
http://forums.openqa.org/thread.jspa?messageID=31350).
The "Remember this Password" dialog
should not appear again after you've
chosen to remember it. Currently there
is not much that can be done about IE
modal dialogs.
I seem to remember someone working around this with an AutoHotKey script that dismissed the dialog.

I have been using Selenium IDE to test jQuery modals for quite sometime now, I never faced any problem. Here are the things I do to ensure that the test executes properly on playback:
execute the script at the slowest possible speed
when the modal opens, I use the waitForElementPresent command to verify the presence of at least one of the constituent elements on the page; argument being, if one element loads properly, it is safe to assume that all the elements and hence the modal window loaded up properly.
Hope this helps. If you want further help, you can share the code with me alongwith the error in execution that IDE throws out to you.

Modal window hacked:)
http://seleniumdeal.blogspot.com/2009/01/handling-modal-window-with-selenium.html

This is how I handle pop up alert in Selenium IDE
right click on the element (in this case your pop up window) there are some command you can choose. There's also a show all available commands whiche might be a help.
You should use AssertElementPreset and I guess the best locator in this case is CSS. So you can choose AssertElementPresent.
Or
you can use two command on Selenium IDE
selectWindow | null
verifyElementPresent | css=div.content
Hope this helps!

Related

How can I Close a popup window, after execute Update SQL. (Oracle APEX 21.1)

I created a pop-up page. That pop-up window has a radio button, a text box, and an execute button. I want to work that page working like... when pressing the button, run a update SQL with the values of the radio button and text box, and close itself.
I tried that answer in the following link. But the pop-up page just reloaded and the page stayed open. How to close popup window in Oracle-apex?
If possible, I would like to validate the value of the text box. If it was an incorrect value then break the process with a message. If path that validation, run a update SQL and close the pop-up window.
Thank you for your kindness for read this confusing question.
You should be using a "Close Dialog" process type after your Save Process.
Make sure that you also set the server side condition accordingly so that the dialog only closes after your save process.
I GOT RESOLVED IT!
Not use any close method, redirect util is fine work like this APEX_UTIL.REDIRECT_URL (APEX_PAGE.GET_URL(p_page => 7));
Thank you to all ppl for look this page :)

Windows 10 - Taskbar - Add item to context menu for each program

I need a context menu entry for each program in the taskbar. Want to add an entry which immediately terminates (UNIX/Linux-like signal SIGKILL) the process. There a lot of questions on this site, how it's done for the explorer or desktop. But is it also possible to add such an option to the context menu of the taskbar?
To clarify the question, according to my comments:
The current problem:
I have a program (not Firefox) which randomly crashes. The program is in fullscreen mode. But if I want to close the window of the program with Exit window, it takes a long time that Windows kill the program. When I try to open the Task Manager the program immediately grabs the user input and I have no chance to interact with the Task Manager. So my solution was to add a context menu item in the taskbar to quit the task of the program. According to a user comment, I test the option "Always on top" in the Task Manager. Didn't know that. But I haven't tried it yet. I'm also interested for further projects, if there is a function in WINAPI or Windows Registry to add an item.
To avoid down-votes:
I'm not interested to hack Windows or the application. Solutions with code injection are taboo for me. Want a clean solution, if even possible. I want improve my Windows version. Adding also some additional information (process information) in the context menu.
Have currently found this (Registering shell extension handlers).
Has anybody used this before? I think it's sound promising.
There is no API to extend this menu like that. Applications can customize the top of the menu with ICustomDestinationList but there is no way to add entries for all applications.
For a personal use project, you could inject a .dll in the taskbar instance of Explorer.exe and add your item after figuring out the address of the function where the menu is created. This address can of course change after you upgrade Windows so it is not a very generic solution. Using the public symbols might help but you still have to expect it to break from time to time when Microsoft changes part of their taskbar code.
You don't need to change code in explorer.exe, because you can close a program by doing the keyboard shortcut: Alt + F4.

Opening and testing a sub-window programmatically made in Vaadin, using Vaadin TestBench

Good day, fellow stackoverflow users. I have a problem using Vaadin TestBench in order to test a sub-window.
To be more specific, I've programmed a "popup" window that will be invoked by the main application when such application fails for whatever reason. As this sub-window doesn't have an URL, it will simply be invoked programmatically. I'm having problems coming up with a way of testing this single sub-window, as I have searched and read the Vaadin documentation, but all examples I see involve creating a driver for a certain browser, invoking a URL, accessing its elements and then doing the tests.
All I want is something like this:
Window popup = new Window() // Create sub-window (popup) programmatically
// instead of navigating to an URL with a web driver
// Here, I select the elements of the popup and do actions on it
// programmatically
...
// End the test and close the popup window
popup.close()
Is there a way of accomplishing this feat? I'm using the latest version of Vaadin on Springboot.
Vaadin Testbench and Selenium use the same base. You can reach the popup in the same way you do in Selenium:
driver.switchTo().activeElement();
or (if it is an alert)
driver.switchTo().alert().submit(); //submit = click OK, maybe it differs from your intention
If your "popup" is a separate browser window, you can switch by windowHandle.
driver.switchTo().window();
Hope this helps :)

MFC application with dynamically created controls suddenly stops responding

I have a MFC application (Visual Studio 2010) which dynamically creates and destroys lots of editboxes, drop-down boxes, and buttons, based on the user's consequent input.
I used "Create" function to dynamically create controls, and when deleting controls the system first calls "DestoryWindow" function for each control, and then delete each control pointer.
After iterating certain amount of creating/deleting controls, if I try to "open" the dropdown menu, the system fails to open it and stops responding to my input - but I can add more controls, if I do not try to open the dropdown menu.
Could somebody please let me know how to workaround this strange issue? This one nearly drives me crazy...
Workaround is simple - don't try to "open" that menu :)
Now I assume that you want to FIX the issue. Then you need to figure out what is going on. The system may be non-responsive for multiple reasons, most likely one of these two:
You are in a busy loop in your main UI thread.
You are waiting for an event that never happens. Deadlock, for example.
When your application is frozen, try to attach debugger to it and do Debug -> Break All. Then see what code is executing. If the reason for this "freeze" will not be obvious, please post relevant code.

Prevent new browser window from opening when running Protractor tests

I'm using JetBrains Webstorm IDE and set it up to run my Protractor tests from inside, and all the command line output shows nicely in the test runner, but the browser window pops up over everything and I find it extremely distracting. Is there a way to stop it from showing? Or forcing it to stay minimized?
This applies to Karma - but maybe you can do the same thing in Protractor.
My horrible hack for this is to launch Firefox with -with-tab instead of -no-remote and set the Firefox tab loading behaviour by using the info at http://www.techsupportalert.com/content/how-stop-firefox-stealing-window-focus.htm - basically by setting browser.tabs.loadDivertedInBackground to true.
This prevents the window stealing focus when you load a new tab. You end up with a lot of tabs though.