How to close or minimize browser windows with Selenium RC? - firefox

Every time I launch a Firefox instance via Selenium RC I get 3 windows that I don't need appearing:
the add-ons windows notifying me that
"3 new add-ons have been installed"
(since I'm using a custom profile for
Selenium to which it evidently adds
the DocumentReadyState, KillFF, and
Selenium RC Runner add-ons)
the http://localhost:4444/selenium-server/core/Blank.html?start=true window
the dual window with two tabs starting with chrome://src/content/RemoteRunner.html?sessionId=... each
I don't need any of these to be visible, and each time I have to manually close the add-ons window, to minimize the two other windows, and to maximize the main browser windows which Selenium controls. After going through this too many times, I got annoyed enough to seek a solution:
Is there any way to automate closing the add-ons window and minimizing the two other windows?
By the way, I'm on OS X so I'd also appreciate some alternative solution which automates this via the OS instead of directly using Selenium.

There's a few preferences you can change in your custom profile to prevent the addons window and the additional tab on startup:
Set the extensions.lastAppVersion preference to the version of Firefox that you have installed.
Set the extensions.newAddons preference to false.
Set the extensions.update.notifyUser preference to false.
There might be some more, perhaps others can provide their suggestions in comments or their own answers.
As long as Selenium is running in multi window mode (the default mode) you'll get two browser windows. You could either maximize the main window using the following command:
selenium.windowMaximize();
Or use the multiWindow command line parameter to disable the use of multuple windows and just use a single window - note that this causes issues on some websites, especially if they attempt to break out of frames.

Related

Use Browser is missing settings like "Private" & "NewSession" in the Modern Design

For me that's a huge step back. The new Use Browser is missing settings like Private & NewSession in the Modern Design. So it's not possible to open Chrome in private mode anymore. So currently the only workaround is to hit CTRL+SHIFT+N as Chrome shortcut:
But for me that does not sound like a good solution as browsers can swap that hotkey or having different.
So before without the Modern Design is was possible to set incognito mode in Open Browser:
So why is that feature gone in the Modern Design rework? How to get it back without the workaround and still using the Modern Design?
Private coming 21.4
New session is gone forever because it was targeting IE only, which is out of support
There is a workaround that already allows the incognito mode now in Chrome:
Add Application/Browser
Add new Chrome Application to the Object Repository (or click Indicate application ...)
Now do NOT create a screen (if the Create screen window is now opened close it)
Select the Use Browser Chrome and go to property Unified Application Target > Arguments
Type in --incognito
Click on the Burger menu of Use Browser Chrome
In the dropdown select Add Screen to Object Repository
Create the Screen now
All done. When you now check Use Browser Chrome for the Unified Application Target > Arguments it should still say --incognito.

The Focus of the Default Sharing Window

I'm using a command-line tool called terminal-share to use the macOS's system sharing service.
The tool's code can be found here:
https://github.com/mattt/terminal-share/
But, there is one little problem with this tool. Since this is a headless command-line application it doesn't have any windows of its own.
And when invoking it (using NSSharingService), it will start a sharing window(the default sharing window), but the sharing window won't have any focus.
So, I must click the post button using the mouse, not by using the CMD + SHIFT + D (or CMD + Enter) to send the share. Since there is no focus(the window that accepts for the key event still is the terminal emulator that starts this application.
This is quite annoying. Is there any better way to fix this?
I've investigated the NSSharingService API, it didn't have any code about the default sharing window. Is there any way just to keep this tool headless, and let the default sharing window become focused when it comes out?
Thanks.

Multiple Instances of Firefox during Selenium Webdriver Testing not handling focus correctly.

I have noticed that while running multiple selenium firefox tests in parallel on a grid that the focus event handling is not working correctly. I have confirmed that when each of my tests is run individually and given focus of the OS the tests pass 100% of the time. I have also run the tests in parallel on the grid with Chrome and not seen the issue present.
I have found the following thread on google groups which suggests launching each browser in a separate instance of xvfb may be a viable solution.
https://groups.google.com/forum/?fromgroups#!topic/selenium-developers/1cAmsYCp2ho%5B1-25%5D
The portion of the test is failing is due to a jquery date picker which is used in the project. The date picker launches on a focus event and since there are multiple selenium tests executing at the same time the webdriver test executes the .click() command but focus does not remain long enough for the date picker widget to appear.
.focus(function(){ $input.trigger("focus"); });
jQuery timepicker addon
By: Trent Richardson [http://trentrichardson.com]
My question is if anyone has seen this before and solved it through some firefox profile settings. I have tried loading the following property which had no affect on the issue.
profile.setAlwaysLoadNoFocusLib(true);
The test fails in the same way as it did before with that property enabled and loaded in the Remote Driver Firefox Profile.
I need a way ensure the focus event is triggered 100% of the time or to solve the issue of multiple firefox browsers competing for focus. Considering Chrome displays none of these issues I wonder if it may also be considered a bug in firefox.
Thanks!
#djangofan: Wrong. You cannot lock the focus. After you requested focus in one window and before you trigger an action, another window requests focus, and your action (like sending keys to input field) just doesn't work. This happened in our tests several times daily. It was hard to reproduce, because with each test run it failed on different places. A solution is to execute each browser in a separate display. E.g. you can use Xvfb:
Xvfb ... -screen 1 1200x800x24 -screen 2 1200x800x24 ...
Then when you start a browser, assign a separate screen to it:
browser.setEnvironmentProperty("DISPLAY", ":N.1");
browser.setEnvironmentProperty("DISPLAY", ":N.2");
...
I've had the same issue in my continuous integration environment with Jenkins.
After a long research i found an old bug in firefox that led to a new config flag to avoid those problems.
The solution is to enable this flag on the firefox profile that the tests use. The flag is focusmanager.testmode, set it to true.
The explanation is that the focus events are triggered only when firefox window is active. If you run multiple test you have multiple windows so only the active one triggers the focus events. With this param the events are trigered even for non active windows.
You can wrangle this and get it under your control with no problem. First write a method to identify the popup window by its window handle id. Then, use a JavaScriptExecutor to execute "window.focus()" in javascript to force the window to be focused just before you perform another action. Then, you can close the popup by its window handle name if necessary.

How can I find out or record the X11 top-level window from which a top-level window was opened?

I'm thinking of writing an X11 window manager which does for windows something like what TabKit does for tabs in Firefox (in its default tree view mode). To do this, I'd need to be to able to find out which window a window was opened from. Is there a standard way of finding this out?
(I've never done any X11 programming without using a cross-platform toolkit on top of X11, let alone writing a window manager.)
For the difficult cases - applications launching other applications, e.g. a word processor launching a web browser - there's going to be a need for co-operation between applications to track this information. The Zeitgeist project already seeks to track which documents were opened from which documents, which is close enough that I should probably work with Zeitgeist (and/or its KDE equivalent - Nepomuk?) to get this implemented.

X11 unable to maximize applications when no window manager is used

We have a Linux based system that does not use a Window manager. When we start certain applications (for instance Firefox) from a terminal window (e.g. Firefox &) we find that no matter what we do, we can't get the application to display full screen.
If we run xrandr, it shows the default resolution is 1280x1024, but when we try to maximize Firefox (by pressing F11) the application is only sized to 1203x650.
Another application that seems to have the same problem is the evince PDF reader.
Our application is not configured to run a window manager (and we don't want to add one), so I'm wondering if there is something else that we can do to get these applications to render full screen.
Thanks...
Although you don't want to use a window manager, you might need to use a window manager.
I haven't dug into the X server sources around this, so I can't definitively say X requires a window manager to run properly. But as somebody who writes X client code, and hacks the X server, on minimalist embedded devices with small screens, low CPU power and no GPU... let's just say, all the major players in that space use one, and have good reasons for it.
If you want to avoid chewing up a lot of disk space, RAM or CPU power doing window management, you should check out matchbox. It's a low-footprint window manager designed to meet those criteria, and it's what many folks in that minimalist embedded space are using. My employer uses it on cell phones, configured so that only one app at a time is visible to the user, and the foreground app takes up the whole screen with no window borders. But you can use it other ways, too - Nokia uses it for their Maemo-based network tablets.
You could use xwit(1) to forcibly resize and place the windows. But as as far as I know, X11 in itself does not have the concept of a "maximized" window; the very idea is only added by most window managers and/or applications (like Firefox).
Does passing the "-geometry=1280x1024+0+0" option to Firefox help?
Oh, also... if you don't explicitly set a window manager, you might be unexpectedly falling back to the default X11 window manager. If you're not absolutely positive there's no window manager, you should check into this possibility.

Resources