Selenium IDE select window in loop? - selenium

I wrote a selenium script that will open a specific URL to then click on button at the index page. After that, a pop up window will show up. The script will click on a button inside this new pop up window, so i need to select that window in order to make a command on it.
So i did (select window) and give it the target (win_ser_1), which belongs to the pop up window and it clicked the button. After that it will select the previous index page (win_ser_local) and start over again and again until the loops end.
The problem is: when the selenium open a new pop up it gives it a target name like this (win_ser_1 ) and when it closes it and opens it again, the pop up will show with a different name (win_ser_2) although i closed the previews pop up before.
So it seems i need to give the select window a new value each time the selenium a open a pop up? If so, I will need to count how many times the script will open a pop up?! But i don't want this, so: is there a simple way fix this?
My commands:

Related

SAP GUI scripting - Button press fails

I am using a macro in an Excel file that runs the SAP GUI. There is a step where, when I click a button in SAP there will be another window that pops up.
For that I have written a code like this:
session.findbyid("wnd[0]/XX/btnXX").press
session.findbyid("wnd[1]/XX/btnXXX").press
There is a button (btnXXX) in the window (wnd[1]). But when I execute this query, I am getting an error object not found for findbyid.
When I keep the break point and execute it, it is throwing error on 2nd line in the above code. I try to pick the activewindow.name and it shows wnd[0] still. Here the issue is wnd[1] is not getting opened.
Does somebody know why the 2nd "button press" doesn't work?
You should be able to replace all mouse clicks with keyboard strokes.
Replace:
session.findbyid("wnd[0]/XX/btnXX").press
With:
session.findById("wnd[0]").sendVKey(N)
Where N is the linked hot-key ID.
To get the exact command, use SAP script recording and only use the keyboard to transition between views and windows. The easiest way to determine how is to hover your mouse over the buttons you would normally click to learn the hot-key then record the hot-key.
Note 1) So far I have found that btn[XX] always maps to sendVKey(XX), but I can't be certain this is always the case.
Note 2) sendVKey always appears to be referenced off the window (wnd[Y]) even if a button is another layer down (/tbar, /usr, etc.).

assertConfirmation not displaying in selenium IDE

I am new to Selenium, I am using Selenium IDE to record test scripts.
I am having trouble while executing one of the recorded test cases in Firefox. It is a simple test case which clicks a button and then clicks on OK button of the pop up window .This is the page link for which I am creating script.
Below are the three steps recorded from IDE
The problem is that after the second step, i.e., click step, no pop up is being shown, the same happens in the next step.
The pop up is not displayed yet the test case gets executed correctly.
Could someone please let me know why I am not able to view the pop up ?

Close nth open window in IE11 using Selenium

On the page "http://www.seleniumframework.com/Practiceform/" There is a button "New Message Window".
I want to hit this button 5 times which will open 5 windows. All the windows have same content. So cant identify specific window using content
i want to close the 3rd window.
I'm only seeing this open the same window multiple times. However, if you want to do this, you would:
Get the current window handles
Switch to the third one
Send your webdriver instance the close command (not the quit command, that will close all windows)
Without knowing what language you're using, I won't be able to give you an example.

How do I get IntelliJ to keep console, db console, etc all visible?

Whenever I run something, the bottom window always fully replaces the other windows. For example, if I first open the Database Tool Window and execute a select statement, it shows the rows in the bottom output. If I then run my java program, it closes that and replaces it with the app's output console. I want them side by side.
How do I tell it what to keep open at the bottom? (I tried pinning a tab but it still goes away)
do you want this?
1
2
try click split mode in your first window (ex Database Tool Window)

Selenium - how to switch to a different (login) window that is brought up?

My application has an admin account and the testing has been within that.
This account then has hyperlinks for 'regular' users that they use for their login, for example:
One http://dmplanning-stage.herokuapp.com/p/7Fimn1FRs1WZe5xmFTUA
Two http://dmplanning-stage.herokuapp.com/p/FRs1WZe7Fimn15TUAxmF
Three http://dmplanning-stage.herokuapp.com/p/mFTUA7Fimn1FRs1WZe5x
These links are generated each time I run the test suite and the id's are different.
I've created a test to locate and click on the hyperlink on a page that lists these users and their login hyperlinks. The test runs and selenium makes the browser bring up the new window but how do I then switch to it, so I can login and continue?
To make it more challenging the other window has an empty title, i.e.
I can get the programmer to add a title but it would take time. Is there any way with/without that to identify and switch to the other window?
I'm assuming you are using Selenium IDE. So from the Selenium Reference
selectPopUp ( windowID )
Simplifies the process of selecting a popup
window (and does not offer functionality beyond what selectWindow()
already provides).
If windowID is either not specified, or specified
as "null", the first non-top window is selected. The top window is the
one that would be selected by selectWindow() without providing a
windowID . This should not be used when more than one popup window is
in play.
Otherwise, the window will be looked up considering windowID
as the following in order: 1) the "name" of the window, as specified
to window.open(); 2) a javascript variable which is a reference to a
window; and 3) the title of the window. This is the same ordered
lookup performed by selectWindow .
selectWindow ( windowID )
Selects a popup window using a window
locator; once a popup window has been selected, all commands go to
that window. To select the main window again, use null as the target.
Window locators provide different ways of specifying the window
object: by title, by internal JavaScript "name," or by JavaScript
variable.
title=My Special Window: Finds the window using the text that appears
in the title bar. Be careful; two windows can share the same title. If
that happens, this locator will just pick one.
name=myWindow: Finds
the window using its internal JavaScript "name" property. This is the
second parameter "windowName" passed to the JavaScript method
window.open(url, windowName, windowFeatures, replaceFlag) (which
Selenium intercepts).
var=variableName: Some pop-up windows are
unnamed (anonymous), but are associated with a JavaScript variable
name in the current application window, e.g. "window.foo =
window.open(url);". In those cases, you can open the window using
"var=foo".
selectWindow would be ideal if you can retrieve the name of the new window that is opened.
If you're having trouble figuring out the name of a window that you
want to manipulate, look at the Selenium log messages which identify
the names of windows created via window.open (and therefore
intercepted by Selenium). You will see messages like the following for
each window as it is opened:
debug: window.open call intercepted; window ID (which you can use with
selectWindow()) is "myNewWindow"
In some cases, Selenium will be unable to intercept a call to
window.open (if the call occurs during or before the "onLoad" event,
for example). (This is bug SEL-339.) In those cases, you can force
Selenium to notice the open window's name by using the Selenium
openWindow command, using an empty (blank) url, like this:
openWindow("", "myFunnyWindow").
You can use the windowhandle to switch to the new window.
Something sort of..
Webdriver driver = new FirefoxDriver();
driver.get // Go to ur login page
driver.click //Click on link which launches new window
Set<String> s = driver.getwindowhandles() //this will return all open windows
driver.switchTo.window(s[1]); //will switch to second window
Hope it helps..