Here's another short and interesting story about problems we have to deal at Browserling. This story is about getting rid of annoying pop-up dialogs in browsers, such as alerts, error dialogs and add-on update dialogs.

So this one time when we were building Testling we started getting a nasty modal dialog in Chrome that paralyzed the browser and the tests wouldn't run. It said:

Your profile can not be used because it is from a newer version of
Google Chrome.

Some features may be unavailable. Please specify a different profile
directory or use a newer version of Chrome.

Here's how that dialog looked in Chrome:


Your profile can not be used because it is from a newer version of Google Chrome.

We were isolating each browser already through Sandboxie so changing the profile directory wasn't really a solution. I decided to write a quick hack that would simply click the OK button on this dialog.

I used Spy++ to find the window class of the dialog:


Spy++ in action.

And then I wrote a Win32 C++ program that detects if this dialog is present, and if it is, it clicks the OK button to get rid of it:

#include <windows.h>
#include <cstdio>

int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    while (1) {
        HWND dialog = FindWindow("#32770", "Google Chrome");
        if (dialog) {
            printf("Found dialog: %x\n", dialog);
            HWND dialogItem = NULL;
            while (1) {
                dialogItem = FindWindowEx(dialog, dialogItem, NULL, NULL);
                if (dialogItem == NULL) {
                    break;
                }
                char windowText[255];
                GetWindowText(dialogItem, windowText, 255);
                if (strcmp(windowText, "OK") == 0) {
                    SetActiveWindow(dialog);
                    SendMessage(dialogItem, BM_CLICK, NULL, NULL);
                    break;
                }
            }
        }
        Sleep(1000);
    }
}

I pushed this program to github and called it chrome-dialog-killer.

Here's another similar problem that we faced in Browserling. We run many different FireFox versions on the same box and often FireFox wouldn't start cleanly. Instead it would complain about incompatible add-ons:

The following add-ons are not compatible with this version of
Firefox and have been disabled.
...
Firefox can check if there are compatible versions of these
add-ons available.

The incompatible add-ons dialog looked like this:


Incompatible add-ons FireFox dialog.

I tried disabling this add-on in all the FireFox version (Firefox 3 to Firefox 25) but we'd still get this alert sometimes. The browser wouldn't start and users had to click the "Don't Check" button. So, again, I used Spy++, found the dialog's windows class and wrote an even simpler program that simply sends the WM_CLOSE message to the dialog that closes it:

#include <windows.h>
#include <cstdio>

int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    while (1) {
        HWND dialog = FindWindow("MozillaDialogClass", "FireFox Update");
        if (dialog) {
            printf("Found dialog: %x\n", dialog);
            HWND dialogItem = NULL;
            SendMessage(dialog, WM_CLOSE, 0, 0);
        }
        Sleep(2000);
    }
}

I also pushed this program to github and called it firefox-update-dialog-killer.

Similarly we can get rid of alert() dialogs in Testling as they're unnecessary and halt the JavaScript execution.

Modern GUIs and interfaces should never use modal dialogs as they provide really unpleasant user experience and make automating things difficult. Until next time.

Comments

Paul Irish Permalink
January 19, 2014, 17:57

While it's not a general solution, for browserling's purposes, I would recommend just establishing a user profile folder for each version of Chrome to avoid this issue.
http://peter.sh/experiments/chromium-command-line-switches/#user-data-dir

January 19, 2014, 22:46

Thanks for the suggestion Paul.

June 20, 2014, 08:42

is amazin help

June 23, 2014, 09:18

Ok it will be superb

June 30, 2014, 10:26

At last you solved my problem

Kaur deep Permalink
December 04, 2014, 03:27

Excellent and knowledgeable links and post.thanks for sharing.
Now, The Time has come for the Happy New Year 2015. It wil bring a lot fo happinesin our life.
Happy New Year 2015
And I am sure, You wil anjoy this new year day with yoru fiends and wil send some images wishes,
New Year 2015

Happy New Year 2015 Wishes
Greetings to yoru close ones, Your friends, You lover, etc..
Happy New Year 2015 Images
Even I am waititng for that day, because it just changes our life.
Happy New Year 2015 Greetings

Happy New Year 2015 SMS
So, That's why I am commenting here to wish you a very happy new year.
Happy New Year 2015 Messages
I hope this New year 2015 wil bring success to your website. But before that Merry Christmas is coming.
Merry Christmas Quotes
It is also a big event for everyone.
Merry Christmas Pictures
Everyone knows that Christmas is a day when People seems to be very happy, they just leave all sadness behind.
Merry Christmas Wallpapers
And I am sure, you also enjoy this Merry Christmas day of 2014.
Christmas day Images

Christmas stocking
But if you are not looking out to enjoy this christmas, then you are missing out on a big thing, because it really brings happiness.
Merry Christmas Images

Merry Christmas 2014
So, what you are waiting for?
Merry Christmas 2015
Enjoy This Merry Christmas day. Cheers :).

Anthony Gonsalvo Permalink
December 05, 2014, 03:57

I am huge fan of Browserling, i was facing similar kind of issue on firefox browser, by going through this post i fixed this issue, thank you for the post. Read more here to find possible ways to reduce the unnecessary hassle of Utility Bills.

Diana Permalink
December 17, 2014, 15:58

This article is quite helpful and informative too. I enjoyed a lot. Thanks for sharing such a great article.

Beautiful Christmas Quotes for your friends and family...
christmas quotes
Christmas Messages for Whatsapp

Best Christmas Greetings for your friends and family...
christmas greeting
christmas wishes

What to Write in Christmas Card....... Check out best Christmas Greeting Card Words
What to Write in Christmas Card

Get Beautiful and Unique Christmas Wallpapers for free
free christmas wallpaper
christmas tree decorating ideas

Thanks for sharing such a great article.

Leave a new comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "server_399": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.

Advertisements