[noob][Selenium IDE] (1) Setting focus to type into a field on a newly opened Tab; and (2) Switching between Tabs

427 views
Skip to first unread message

MEA Engg QA

unread,
May 25, 2020, 12:09:49 PM5/25/20
to Selenium Users
I am new to Selenium IDE, and have no prior Automation/Scripting/Coding experience.

Here's what I have in my script in Selenium IDE:
----------------------------------------------------------------
Playback base URL: https://www.google.com

Step (1): Open Chrome, then navigate to the base URL 
Command: open
Target:  /


Step (2): Opening a new Tab with https://www.mailinator.com as an adjacent Tab
Command: execute script
Target: window.open("https://www.mailinator.com/","_blank")


Step (3): Input Email Address in the text field 'Enter Public Mailinator Inbox'
Command: type
Target: vi_NoDel...@mailinator.com


Step (4): Click on the 'GO' button for the field 'Enter Public Mailinator Inbox'
Command: click
Target: id=go-to-public

Now, there are two Tabs open: "Tab=0" and "Tab=1":
Tab=0: Page contains the Forgot Password reset Form with the field 'Confirmation Code'.
Tab=1: Email that received the Forgot Password reset Email with the 6 digit 'Confirmation Code'.

PROBLEMS:
Problem#1: I am having consistent failures on Step (3) - my script is unable to either get focus on the new Tab ("Tab=1") and/or, is unable to get focus on the text field 'Enter Public Mailinator Inbox' (to be able to type into this text field) - I need to input the Email address into the text field 'Enter Public Mailinator Inbox', click on 'GO', and from the Email, I need to copy the 6 digit (Confirmation) 'Code'.

Problem#2: I am having trouble switching back to "Tab=0". After copying the 6 digit (Confirmation) 'Code' from the Mailinator Email, I need to return to "Tab=0", paste the 6 digit (Confirmation) 'Code' into the 'Confirmation Code' field in my App.

I am over-simplifying the problem here (by replacing my App's page) with google.com so I can overcome Problem#1 first, but have had issues with switching between tabs before.

Here's what I have tried so far:
store window handle - for both the Tabs, the handle ID is the same;
select window - throws error "No such window locator".
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
(1) Am including .SIDE file to illustrate the steps...
(2) I am including 3 screenshots below with a few notes:
Tab=0: Need to retain this page with the Form in order to complete the Password reset:

forgotPwdConfirmationCd_Tab=0.PNG


---------------------------------------------------------------------------------------
Tab=1: Page-1: Need to input the Email Address and click 'GO' to gain access to the Email;

mailinatorInputEmailAddress_Tab=1_Page2.PNG



After the Step above, an intermediate page appears with the Inbox which, when clicked on, shows the User the page below.
---------------------------------------------------------------------------------------

Tab=1: Page-2: Need to copy the 6 digit (Confirmation) 'Code', then return to Tab=0 (above) and paste it into the field labeled 'Confirmation Code'.


mailinatorConfirmationCd_Email_Tab=1_Page3.PNG


After copying the 'Code' I do not care about the "Tab=1, Page-2" anymore.

Any guidance/help is very much appreciated!

Thank you
M

052420_wip4E_side.side

MEA Engg QA

unread,
May 25, 2020, 12:16:00 PM5/25/20
to Selenium Users
A quick update to a sentence below, which should have read as follows:
After copying the 'Code' I do not care about "Tab=1" anymore.


On Monday, May 25, 2020 at 12:09:49 PM UTC-4, MEA Engg QA wrote:
I am new to Selenium IDE, and have no prior Automation/Scripting/Coding experience.

Here's what I have in my script in Selenium IDE:
----------------------------------------------------------------
Playback base URL: https://www.google.com

Step (1): Open Chrome, then navigate to the base URL 
Command: open
Target:  /


Step (2): Opening a new Tab with https://www.mailinator.com as an adjacent Tab
Command: execute script
Target: window.open("https://www.mailinator.com/","_blank")


Step (3): Input Email Address in the text field 'Enter Public Mailinator Inbox'
Command: type
After copying the 'Code' I do not care about "Tab=1" anymore.


Any guidance/help is very much appreciated!

Thank you
M

Adrian

unread,
May 25, 2020, 10:13:14 PM5/25/20
to Selenium Users

Hi MEA Engg QA,
I am using C# to answer this question.

To get focus on the tab and enter the email address then use some code like this:
NOTE: - You may need to add some code to wait for the email field to be available, before trying to fill it out.

var originalTab = driver.CurrentWindowHandle.ToString();
var tabList = driver.WindowHandles;
foreach (var tab in tabList)
{
    driver.SwitchTo().Window(tab.ToString())
    if (driver.Title == "Mailinator")
    {
        driver.FindElement(By.Id("addOverlay")).SendKeys("Em...@somewhere.com");
    } 
}


To close the tab when you are finished, use the following:
driver.Close();


Then you will need to switch back to your original tab
driver.SwitchTo().Window(originalTab)


I hope this helps,

Regards,
Adrian.



On Tuesday, 26 May 2020 02:16:00 UTC+10, MEA Engg QA wrote:
A quick update to a sentence below, which should have read as follows:
After copying the 'Code' I do not care about "Tab=1" anymore.

On Monday, May 25, 2020 at 12:09:49 PM UTC-4, MEA Engg QA wrote:
I am new to Selenium IDE, and have no prior Automation/Scripting/Coding experience.

Here's what I have in my script in Selenium IDE:
----------------------------------------------------------------
Playback base URL: https://www.google.com

Step (1): Open Chrome, then navigate to the base URL 
Command: open
Target:  /


Step (2): Opening a new Tab with https://www.mailinator.com as an adjacent Tab
Command: execute script
Target: window.open("https://www.mailinator.com/","_blank")


Step (3): Input Email Address in the text field 'Enter Public Mailinator Inbox'
Command: type

MEA Engg QA

unread,
May 29, 2020, 10:47:26 AM5/29/20
to Selenium Users
@Adrian: Thank you for the post.

Not being a scripter / coder and being new to Selenium IDE, am wondering if the C# code translates into the Selenium IDE, and if it does, how do I used it in Selenium IDE's  "Command" | "Target" | "Value " fields?

Thank you

Adrian

unread,
May 31, 2020, 5:20:34 PM5/31/20
to Selenium Users
I have never used Selenium IDE, but you should be able to translate the code into something that you are familiar with.
If you are not using C# are you using Java Script?

The Selenium commands I have used should be the same for you.  So the FndElement() and the SwitchTo() call should be the same.  Then you just need to loop around to find the correct window title.

Gina Doll

unread,
Sep 3, 2020, 6:43:41 PM9/3/20
to Selenium Users
I am no expert, for sure, but I've so far learned part of what you're trying to do. Before you open the new tab you need to store the handle of the current window into a variable, like "root". It looks like this:

Command: store window handle
Target: root

When you want to switch back to that tab later, the code looks like this:

Command: select window
Target: handle=${root}

For both of these instances, Value is empty.

I hope this helps!
Gina

Reply all
Reply to author
Forward
0 new messages