Selenium2Library - Selects window but fails - selenium2library

I have an issue trying to select a window using Select Window command. There is no title for the window when I select it but when I try
Select Window title=Mozilla Firefox
it selects the window but then returns ValueError and fails. The window is a Popup window after selecting a button on another page. I have tried using url and also javascript but still returns the same error. Any help would be appreciated.
Thank you,
Kyle

Related

Is there any way to change focus of browser tabs in robot?

I am using robot framework+python+selenium to create an automation framework.
I am stuck at this point.
On this website. When the link 'a' is clicked, a new tab is opened. On this new new I want to test functionality. My problem is I'm not sure how to change the focus from one tab to another. I tried the switch browser keyword as well as the select window keyword. No luck.
You can make use of the following code change focus of the windows using selenium2Library.
#{windows_num} = List Windows
${nWindows} = Get Length ${windows_num}
${latest_window} = Evaluate ${nWindows}-1
Select Window #{windows_num}[${latest_window}]
Found a simple solution here, that worked for me:
https://www.youtube.com/watch?v=5tVgC-oQVKs

Selenium IDE select window in loop?

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:

Robot Framework - Selenium2Library - Chrome & Edge open new tab instead of window

Sorry if this is a mundane question.
My issue is that the user can click on the "Help" button, which by default will open in a new tab, the help page.
When firing the test in Firefox, it creates a new window. Which is great as I can use the Select Window keyword and give it the URL. However, with Chrome and Edge, it just makes a new tab.
I read that Tabs aren't supported - But the weird part is, the test on Edge passes fine, it is just Chrome which is having the problem. Is there a reason behind that?
Is there a way to force it to be a Window and not a Tab? Or something?
I read that I can input a keyboard shortcut of CTRL + Tab. But that feels really dirty and would prefer a better way of doing it.
Error:
ValueError: Unable to locate window with URL 'http://...
EDIT
OK - So instead of using the URL param, I tried the title instead. Just on a whim. And it worked (?) I have no idea how it worked and why using the URL didnt and the title did: Here are the lines I used:
Run Keyword If '${Browser}' == 'Chrome'
... Select Window 1.7.1 User Guide
... ELSE
... Select Window 1.7.1 User Guide - Welcome to the User Guide
Still though, both the "Gets" did not produce a link to the newly created tab / window though :/ - Many thanks to shicky and Helio!
Are tabs not handled largely the same as windows? You should be able to identify what is on the screen as #Helio says by using one of the following:
Get Window Identifiers
Get Window Names
Here are some similar questions that should help you get started, post back here with some further detail if you need more help.
How to get the current URL in Robot framework?
How to make chrome display on the top opened in selenium [Mac OS X]

Selenium Webdriver 2.30 unable to identify object on the standard Salesforce lookup pop-up window

I am using Selenium Webdriver to automate functional TC in Salesforce application.
Test Scenario:
- On a case page, clicking the "Lookup" i.e., search icon opens up standard Salesforce search popup. I need to input specific string to the search field and click "Go" button.
Although I am able to click on the Search button, the script fails to identify any field on the popup.
I used Alert(), getWindowHandle & iterator functions to verify if the driver is working on the popup window. Yes it is.. the popup is is the working window. I could able to confirm this using the Java id for the browser window. But still it fails to identify any fields.
Let me know if any of you faces similar issue and any solution.
Do let me know if you like to have access to my working sandbox. Would be able to manage it.
Thanks, Manju
I believe the problem is that the elements inside the popup window are in a frame. After switching to the new popup window you need to switch to the frame first before being able to access any of those elements using:
WebElement frameLocator = driver.findElement(By.id("searchFrame"));
driver.switchTo.frame(frameLocator);
Further to Bob's answer you'll also then need to switch to the "resultsFrame" in order to use any of the links returned by the search. Note that in order to switch to a sibling frame you must first go up to the parent of the frameset using:
driver.switchTo().defaultContent();
(frameset guidance here: http://darrellgrainger.blogspot.co.uk/2012/04/frames-and-webdriver.html)
With Selenium IDE:
I was able to select the Salesforce PopUP with this code:
Command:selectPopUp
Target:
Value: Your popUp title
And the result frame:
Command:selectFrame
Target: name=resultFrame
Value:

How to enter the credentials in a new window using Selenium?

I need to enter credentials in a new window opened using Selenium. I am using selectWindow command but the name of the window is dynamic. Please suggest how can I handle this.
Thanks
First get the main window handle (getWindowHandle()) before opening new window.
Using getWindowHandles() you can get all opened window handles.
Using above two things try to get newly opened window handle.
Refer below link for full logic .
http://santoshsarmajv.blogspot.in/2012/04/how-to-switch-control-to-pop-up-window.html