window minimize

1,540 views
Skip to first unread message

dnessett

unread,
Aug 12, 2010, 11:44:15 AM8/12/10
to Selenium Users
The Selenium API has a windowMaximize action. However, it does not
have a windowMinimize action. The latter is useful when using Selenium
for regression testing. In such an application, a developer does not
want windows popping up all over the place during the test (speaking
from personal experience). Generally, the developer will be working on
other things during the regression test and windows popping up
significantly interferes with that.

Is there any way with the current API to minimize a window?

Dan Nessett

dnessett

unread,
Aug 12, 2010, 11:57:29 AM8/12/10
to Selenium Users
I need to clarify this question a bit. I need a way to specify that
both the browser window(s) and the selenium-rc window are minimized.
Preferably this would be a selenium-server option, but if that is not
available, then an action to minimize both browser and selenium-rc
windows would work.

Dan Nessett

kamalakar vadla

unread,
Aug 12, 2010, 12:53:53 PM8/12/10
to seleniu...@googlegroups.com
Work around for this prob is run selenium tests against remote selenium server.

-- VK

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.




--
Kamalakar.Vadla
Pramati Technologies Pvt Ltd
Begumpet

dnessett

unread,
Aug 12, 2010, 1:44:33 PM8/12/10
to Selenium Users
Thanks for the reply Vadla. However, this isn't really a solution to
my problem. I am doing code development on my PC. I am working on a
solution that starts up the selenium server for developers on their
local machines from a run-test script. So: 1) I don't have a remote
machine to use, and 2) even if I did, that wouldn't help me test the
code I am writting.

Regards,

Dan Nessett
> > selenium-user...@googlegroups.com<selenium-users%2Bunsubscribe@go­oglegroups.com>
> > .

kamalakar vadla

unread,
Aug 12, 2010, 1:51:41 PM8/12/10
to seleniu...@googlegroups.com
Where you deploy your code?
if it is on local then ? can you make it accessible from remote machine as per my knowledge you can bind your ip to local appserver to be accessible remotely rt?? 
You can actually manage to work this but this is bit complex.
You can try this if u dont have any other workarounds?



-- VK

To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

AJ

unread,
Aug 13, 2010, 1:07:44 AM8/13/10
to Selenium Users
Hi,
I faced the same issue. The solution we finally had was to write a
shell script ( for linux) and a vbscript (for windows). Copy that to
the machine where you are running the test. Call this file using
getEval(javascript call)

regards
AJ

dnessett

unread,
Aug 13, 2010, 11:37:44 AM8/13/10
to Selenium Users
Hi AJ.

I'm sorry I don't follow your solution. Just to set the context, I am
working on a single machine doing development for open source
software. I am not working in a environment where I have multiple
machines, one of which can act as a server and the other as a test
client. What does the shell script do? Since getEval executes
javascript, I don't understand its relation to the shell script?

Regards,

Dan Nessett

Mintaka

unread,
Aug 13, 2010, 4:55:59 PM8/13/10
to Selenium Users
I join to this wishes.
If exist option like:
java -jar selenium-server-standalone-2.0a5.jar -windowMinimize
it will be usefull.

Ashish Joshi

unread,
Aug 14, 2010, 4:24:19 AM8/14/10
to seleniu...@googlegroups.com
Hi,

You can try with following code.

//=========================================================================
                selenium.keyDownNative(""+java.awt.event.KeyEvent.VK_WINDOWS);
Thread.sleep(500);
selenium.keyDownNative(""+java.awt.event.KeyEvent.VK_M);
Thread.sleep(500);
selenium.keyUpNative(""+java.awt.event.KeyEvent.VK_M);
Thread.sleep(500);
selenium.keyUpNative(""+java.awt.event.KeyEvent.VK_WINDOWS);
//=========================================================================


I hope above code suffice your needs (Which will minimize all windows, Again if you want to maximize the selenium window then you can maximize the window and do focus on it using selenium.).

-- 
Best Regards,
Ashish Joshi

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

dnessett

unread,
Aug 14, 2010, 1:16:46 PM8/14/10
to Selenium Users
Thanks Ashish,

I am using PHP, not java, but I think I can convert your code into PHP
without a great deal of effort. I will give it a try and report back
what happens.

Regards,

Dan Nessett
> > selenium-user...@googlegroups.com<selenium-users%2Bunsubscribe@go oglegroups.com>
> > .

dnessett

unread,
Aug 14, 2010, 1:31:20 PM8/14/10
to Selenium Users
Hi Ashish,

I just looked up the java.awt.event.KeyEvent numeric codes. It appears
VK_WINDOWS is an MS Windows only code. I am using Linux and in any
event the solution should be OS independent. Is there an OS
independent way of achieving the same thing?

Dan

On Aug 14, 1:24 am, Ashish Joshi <ashish.josh...@gmail.com> wrote:
> > selenium-user...@googlegroups.com<selenium-users%2Bunsubscribe@go oglegroups.com>
> > .

Mintaka

unread,
Aug 14, 2010, 2:23:49 PM8/14/10
to Selenium Users
Thanks for reply.

I'am using selenium RC on Linux with Python.
Can be that code rewrited under Python?

IMHO the clear solution seems to me option for server, because it will
be platform and language independent.

----
In Gnome can be used as a silly workaround short key CTRL+ALT+d
which minimize all windows.

dnessett

unread,
Aug 14, 2010, 2:46:06 PM8/14/10
to Selenium Users
I agree this should be a server option. I have just investigated using
selenium.keyDownNative() to solve the problem. Unfortunately, the
exact key strokes required are both OS and desktop environment
dependent (i.e., Mac OS: Aqua; Linux: KDE, GNOME, xfce; Windows; and
many others - see: http://en.wikipedia.org/wiki/Desktop_environment#Examples_of_desktop_environments).
Programming a solution for all of these would be a complete nightmare.
So, I think the sever should have two additional options: -
minimizeServer and -minimizeBrowser (or whatever names people choose).
The first would start the Selenium-RC server with its window minimized
and the second would start the browser (and all subsequent children
windows) minimized.

Dan Nessett

Ashish Joshi

unread,
Aug 15, 2010, 1:42:59 AM8/15/10
to seleniu...@googlegroups.com
Hi,

I do not have any idea about other Operating System, but for Linux, you may try out following keyboard shortcut.

Ctrl + Alt + d =  Minimizes all windows, and gives focus to the desktop.



Regards,
Ashish

Ashish Joshi

unread,
Aug 15, 2010, 1:43:08 AM8/15/10
to seleniu...@googlegroups.com
Hi,

I do not have any idea about other Operating Systems, but for Linux, you may try out following keyboard shortcut.

AJ

unread,
Aug 15, 2010, 1:32:04 PM8/15/10
to Selenium Users
Ashish, I am not too sure why, but that didnt work for me. I did try
that. Also, as Dan mentioned this differs across the OS. So if you are
running your RCs on a mix of Linux + Windows machines (which is my
case) then this wont work.

@Dan
You need to write a shell script which will minimize all the open
windows. You can google for this :). Once you write this script, save
it in your machine (say under /opt )
In selenium code, write the Eval function to call this script. Yes
Eval executes only java script, but we can make java calls also in
java script provided your browser has java execution.
Example selenium code would be like this:
selenium.getEval("java.lang.Runtime.getRuntime().exec(\"bash /opt/
scripts/minimize.sh\")");

java.lang.Runtime.getRuntime().exec(\"bash /opt/scripts/minimize.sh\"
- this is a stand alone java code which can execute the scripts.

Hope its clear

regards
AJ

Mintaka

unread,
Aug 15, 2010, 6:34:46 PM8/15/10
to Selenium Users
[python][rc]

The workaround with external script in Python can be executed by
commands:

import subprocess
subprocess.call('/path/script_name.sh')

where script_name.sh can contain bash commands

About subprocess command:
http://docs.python.org/library/subprocess.html


Bash command for minimize windows is depend on active window manager
(Gnome/GTK/...)
or must be used some other utility which hide that differences.

While searching for some example I found "Devil's Pie" project, for
manipulation with windows.
Devil's Pie script for starting firefox windows minimize,
writen for example in file ~.devilspie/minimize_firefox.ds,
can be:

(if
(is (application_name) "firefox-bin")
(begin
(maximize)
)

Two links to Devil's Pie documentation can be helpfull
http://live.gnome.org/DevilsPie
http://foosel.org/linux/devilspie

If somebody successfully build solution, describe us your solution
please.

dnessett

unread,
Aug 16, 2010, 1:36:05 PM8/16/10
to Selenium Users
AJ. Actually, what I want to do is minimize only the Selenium-RC
server window and any windows the server creates (e.g., the browser
window and its pop-ups). I don't want to minimize all windows because
they may be tied to applications the developer is using while running
a regression test in the background.

I am not intimately familiar with Java UI programming, but I found
this: http://www.jguru.com/faq/view.jsp?EID=53754. It appears to be
trivial for the selenium-server to minimize its own window. In order
to start a browser minimized, I found a firefox addon that adds a
firefox startup option for opening minimized. It should be possible
for the selenium server to use this option to start firefox in a
minimized state. However, this doesn't address the problem for other
browsers.

Dan
> >http://www.novell.com/coolsolutions/tip/2289.htmlhttps://help.ubuntu....
>
> > Regards,
> > Ashish

dnessett

unread,
Aug 16, 2010, 1:38:44 PM8/16/10
to Selenium Users
I forgot to provide a reference to the firefox addon that I mentioned
in my last post. It is here: https://addons.mozilla.org/en-US/firefox/addon/2831/.

Dan

dnessett

unread,
Aug 16, 2010, 6:10:25 PM8/16/10
to Selenium Users
I tried this add-on and thought I would report back my experience. The
add-on referenced in my previous post does not work properly with
Ubuntu 8.04. There is another add-on, Minimize on Start and Close that
does work. It is found at: https://addons.mozilla.org/en-US/firefox/addon/48585/.
I had to set the delay to 1000ms (in preferences) in order for the
minimize on start option to work. However, while it works when you
fire up firefox through the normal script, it doesn't work if you fire
it up from the binary (which is what is required for selenium).

Dan Nessett

Mintaka

unread,
Aug 16, 2010, 11:10:37 PM8/16/10
to Selenium Users
Thanks for tips.

I made simple Firefox extension that only minimize browser windows
after start.
It can be helpfull.


Link is here:
https://docs.google.com/leaf?id=0BzLhSj5UgVUyODQxYjM0NTgtYmJlOS00MGZlLTk3MDgtYjUzNDQzZjdlMTFk&hl=en

dnessett

unread,
Aug 17, 2010, 2:46:22 PM8/17/10
to Selenium Users
I have figured out why the Minimize on Start and Close addon was not
working and fixed the problem. Specifically, selenium was using a
fresh firefox profile when starting up the browser. This behavior can
be overriden using the -firefoxProfileTemplate option on the selenium
server command line. After employing this option, the firefox browser
now minimizes when a test run begins. Instructions how to setup this
configuration are found here:
http://en.citizendium.org/wiki/User:Dan_Nessett/Technical/Minimizing_Firefox_on_Startup.

This strategy does not fix the problem of selenium server window
minimization. I still believe there should be a server option that
starts that window minimized.

Dan Nessett

Mintaka

unread,
Aug 17, 2010, 4:09:18 PM8/17/10
to Selenium Users
I should highlight it.
I allways run server with "-firefoxProfileTemplate /path/to/prepared/
firefox/profile"
So I can prepare profile (add extensions, disable/enable options, ...)
and selenium, when open browser make it's copy of that profile.


At the end, Minimize extension is only workaround for lack in Selenium
server options.
Hope Selenium server will grow up, and this (and many other) abilities
will be present.


dnessett

unread,
Aug 18, 2010, 1:58:16 PM8/18/10
to Selenium Users
I have added a feature request that the selenium server support
minimize windows options. You can find it at:
http://code.google.com/p/selenium/issues/detail?id=737.

Dan Nessett

Yuping Zhong

unread,
Aug 19, 2010, 1:29:44 AM8/19/10
to seleniu...@googlegroups.com
Guys,

Anyone consider running this script without open the FF?

I think that will be more convenient.

Thanks!

Alexander Kamyanskiy

unread,
Aug 19, 2010, 10:01:35 AM8/19/10
to seleniu...@googlegroups.com
I'm use Oracle virtual box on my workstation with Ubuntu. I'm develop my tests and run Selenium RC therein. Mozilla's  window  startup  in there it, and I'm can control test process any time. One little problem, the workstation must have enough RAM for use Vbox.

Mintaka

unread,
Aug 19, 2010, 4:40:02 PM8/19/10
to Selenium Users
For my task will be running test without openning Firefox better then
just minimize windows.
I expect better performance, lower CPU and RAM consumption.

I asked for some solution:
How to hide/disable Selenium Remote control window?
http://groups.google.com/group/selenium-users/browse_thread/thread/68272d1fc647df8c/1dc829b56907a77f?hl=cs#1dc829b56907a77f
But nobody answer.

You asked too:
Can run the selenium script without opening the browser???
http://groups.google.com/group/selenium-users/browse_thread/thread/b73589f8004751c1/efe8df2e9b3a83ae#efe8df2e9b3a83ae

Unfortunately, the advices aim to antoher technology.


Reply all
Reply to author
Forward
0 new messages