How do I open a new private window in Selenium IDE and switch between windows? - testing

I'm trying to make automated tests for a site, using Selenium IDE (not Selenium Server, RC, 2.0, and WebDriver).
I want to be logged in with user 1 in Firefox window 1 and open a Firefox private window to sign in with user 2. I need this because the website I want to test doesn't allow multiple users signed in in the same browser at the same time.
So:
1) Is there a way to open a private/incognito window?
2) How do I then switch back to the main window?
Here's how switching between simple windows looks like:
http://i.stack.imgur.com/P5bbt.png

In the attached image you can see how I solved the problem:
It works fine with Firefox version 42.0 (and earlier versions). With Firefox 43 I have some problems because "openWindow screen2" does not overwrite my window I open with javascript but opens an own window. I'm looking for a solution for this issue.

As far as I'm aware this isn't something that Selenium IDE can do. The best solution I can think of would be to use something like Autohotkey and combine the it with Selenium.
With AHK you can set a script to mimic the keyboard command to open a private window (ctrl+shift+p). When I've used it with selenium in the past I've set the AHK script to start when it detects a certain window title, and then had selenium call a javascript function from the user-extensions to amend the title of the page you're on to the title which will trigger the function when you need the AHK script to run. (Best not to use the default one, otherwise you could end up with countless private windows if it hits that page multiple times).

Try this,
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.private.browsing.autostart",true);

Related

How to handle window open prompt(native) in webdriver.io

I am using webdriver.io framework. At my application, I have a button that opens a Windows Open prompt (Native), and there I need to choose a folder/file and click Open.
Then returning to my application and continue.
Is there a way to move focus on to this window and control it (Select a path and click Open)?
If not- Is there any other solution someone can offer?
The short answer is probably not, you can't control native dialogs from webdriver.
If it's a file input type for which you want to set a file, you might possibly use webdriver to evaluate a piece of javascript to set the HTMLInputElement.files value of the input element.
This works in modern browsers as mentioned in the mozilla docs

Open a link in new tab using Selenium IDE

I have looked at many answers
Selenium IDE:Opening in new tab and shift focus to new tab not working
How to open link in new tab etc....
posted regarding this question but not even a single one is 100% relevant therefore, I am asking this again.
I need to open three different links:
google.com
yahoo.com
microsoft.com
in three different tabs but under same window and I am using selenium IDE, I know, it is easier using WebDriver but unfortunately I am using IDE. If I use Open it just opens the next link in the same tab and when I use OpenWindow or openWindowAndWait, it just opens the new window which I do not want.
Can someone please help..
There's no command within Selenium IDE which directly relates to Tabs, Selenium IDE is just not built to work with them. There's a post fro ma few years ago which references an answer from a selenium dev stating this (Selenium IDE for Firefox Ctrl-Tab)
The only way to potentially get it working would be to use send Keys to simulate Ctrl+T to open a new tab. There's a post here which gives details on it.

Reuse existing firefox instance with selenium and capybara

currently during debug of test cases selenium is opening a new firefox window, in whatever desktop screen it chooses. I want to be able to have selenium attach to the existing window (and not close the window when the test is over.)
I see this in the selenium documentation
webdriver.firefox.useExisting Never use in production Use a running instance of firefox if one is present
but I do not see how to set it from rails/rspec/capybara
I have looked at the related SO answers, and they are more to do with attaching to a running test. I just want to control where the window is, and be able have the window open with the developer console, so we can see what is going on, and finally have the window stay open at the end of the test
Depends on the issue 2163 it was a feature of Selenium 1 and not implemented to Selenium 2 but still stays in documentation. Check this issue.

Selenium IDE unable to open new windows from link when running through testcase

So I'm writing tests for a web page, and one of the tests include clicking a link, which opens a new window, do some assertions in that window, and jump back.
To open links I'm using the technique described here.
The weird thing is, when I go through the steps manually (just press all of them one after another) it works fine. But when I try to run the whole test, it either does nothing (no windows open) or it clicks another button (and not the link).
What can be the reason for it working when i do the steps manually, and not when Selenium IDE runs them for me?
To open link, you can use
click | link=link name
selectWindow | windowname
And then perform operation on that window

How to force selenium to detect open window?

js gets downloaded to browser cache.
js contains functionA that constructs the url and calls the window.Open to open the url.
i call the functionA to open the window.
selenium doesnt detect the window at all. i did getAllWindowTitles and getAllWindowNames, etc. But do not see window at all.
by the way the reason i had to this is because when i click on button that has an onclick='calltofunction()', the window is not detected either.
it would be better actually if i can force selenium to see the open window after i click the button.
Thanks!
The straight forward answer that I can think of right now is to move on to Selenium 2.31.0, which has an updated support for WebDriver, and can be used in parallel to Selenium.
Then, it is easy to do ALT+TAB (for Windows, or CTRL+TAB for tabs), and WebDriver picks up the new tab/window and reads off of it.