Ask a Question

How to run a TestComplete test between mutiple instance of Chrome using different user profile

SOLVED
nedbacan
Frequent Contributor

How to run a TestComplete test between mutiple instance of Chrome using different user profile

Hello.

In Test Complete, Is it possible to open two instances of Chrome at the same time using different user profile, and executing the tests between both profiles?

 

The reason of my question is that I have the following manual test case I would like to automate using 2 chrome sessions running at the same time. It is important for both Chromes not to use the same user profile.

 

             1) Launch Chrome (1) using profile(1)

  •     2) On Chrome (1) - Log on as user1 onto the web app.
  •     3) On Chrome (1) - Create a patient and assign patient to user 2.
  •     4) On Chrome (1) - Make the call for user2 to accept the patient.
  • 5) Start another session of Chrome, but with profile (2) and keeping the other session of Chrome(1) opened.
  •     6) On Chrome (2) - Log on as user2
  •    7) On Chrome (2) - Check patient is in user 2 list.
  •    8. On Chrome (2) - Accept user 1 call and perform a few actions.
  •    9) On Chrome (2) - user 2 return patient to user1
  • 10) Return to Chrome (1) 
  • 11) On Chrome (1) - User 1 ends the patient visit after a few actions
  • 12) Both users logs out.
  •  
  • I hope someone can help explain how it can be done by example. 

Thank you.

23 REPLIES 23
rraghvani
Champion Level 2

I was hopeing that the first photo would give an indication on "how" to set this up.

 

See About Tested Applications

nedbacan
Frequent Contributor

@rraghvani , everything works great with both browser launching at once or one at a time, but I am having an issue with trying to interact with the 2nd launch.  Here is my scenario.

 

The first script launches chome1 with a logon screen, and goes through a successful login.

The second script launches chrome2 with the same logon screen, but it fails "Unable to find the following object when executing the SetText commmand", this is the username text box.

 

On the desktop, this is what I see:

  1. The first browser (chrome1) has the landing page.
  2. The second browser (chrome2) remains on the logon page because it fails to find the object.

Both scripts work fine when I run it individually, one browser only. 

Also, if I was to open chrome1 with Google, I can run the 2nd script and logon with no problem. 

 

First Script

 

function Logon_Store1()
{
  //Call TestApp.Chrome1
  TestedApps.chrome1.Run();
  //Logon store user
  let storeuser = Aliases.browser.pageLogInToApplication.formKcFormLogin.textboxUsernameOrEmail;
  storeuser.SetText("userstore1");
  
  let Password = Aliases.browser.pageLogInToApplication.FindElement("//input[@id=(//label[contains(.,'Password')]/@for)]")
  Password.SetText("password!!");

  Aliases.browser.pageLogInToApplication.formKcFormLogin.submitbuttonLogIn.Click();
  
  Sys.WaitBrowser(50000)

}

 

Second script

 

function Login_Phy1()
{
  //Call TestApp.Chrome2
  TestedApps.chrome2.Run();
  
  //Enter Username
  let storeuser = Aliases.browser.pageLogInToApplication.formKcFormLogin.textboxUsernameOrEmail;
  storeuser.SetText("physican1");
  
  //Enter Password
  let Password = Aliases.browser.pageLogInToApplication.FindElement("//input[@id=(//label[contains(.,'Password')]/@for)]")
  Password.SetText("password!!");
  
  //Click log on button
  Aliases.browser.pageLogInToApplication.formKcFormLogin.submitbuttonLogIn.Click();
  
  Sys.WaitBrowser(80000);

}

 

 

Marsha_R
Champion Level 2

@nedbacan I'm still curious - what is your use case for this? Is there actually a point where you will have an admin and a user logged on to two browser tabs on the same screen in actual usage? I'm not understanding how this works.

nedbacan
Frequent Contributor

The reason is that the web application being tested can only have one session opened at a time.  

If I was to launch the Chrome browser (chrome1) and logon to the app as user1.

Next launch another Chrome browser (chrome1) and call the app.

Then logon as another user (i.e Admin) it will display "You are already logged in"

Even if I am logging on as a different user.

If I continue, it will end the first launch session that I opened and keep the 2nd one. 

 

@Marsha_R , I am not referring to two browser tabs, but having two Windows of chrome open at once. 

 

Here is my use case reason:

I need two windows open of chrome to test the interaction between users.

For instance, when user-1 creates an item in his page,

the other user-2 gets a message or a button becomes enabled

Some of the features will not be available unless both users are logged on at the same time.

Both users need to be logged on for some of the features on the app to work. 

 

This test is done manually by opening two Chrome browsers with different profiles. This way, it is being treated as a different login instance.

 

I hope I explained myself.  Thank you for asking. 

rraghvani
Champion Level 2

In both of your codes,

 

//Call TestApp.Chrome1
TestedApps.chrome1.Run();

//Logon store user
let storeuser = Aliases.browser.pageLogInToApplication.formKcFormLogin.textboxUsernameOrEmail;
storeuser.SetText("userstore1");

/////////////////////////////////////////////////////////////////////////////

//Call TestApp.Chrome2
TestedApps.chrome2.Run();

//Enter Username
let storeuser = Aliases.browser.pageLogInToApplication.formKcFormLogin.textboxUsernameOrEmail;
storeuser.SetText("physican1");  

 

You have defined a name mapping Aliases.browser.pageLogInToApplication.formKcFormLogin.

 

How does TC know which browser to interact with, if you are using the same alias name?

 

 

 

 

Hi,

 

How Aliases.browser is defined in your NameMapping?

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
nedbacan
Frequent Contributor

I used the Spy tool to capture the text boxes for each browser that was launched.  I took the Aliases provided in the spy tool.

 

Should it be different?  

 

Chrome 1 > User name text box

nedbacan_3-1674740549244.png

Chrome 2 > Username text box

nedbacan_5-1674740609293.png

 

 

 

 

 

 

rraghvani
Champion Level 2

The screenshots you have provided for Chrome 1 and 2, the properties are exactly the same. Therefore TC can't distinguish between the two objects you are referring too.

 

You must instruct TC, as to what browser you want to interact with.

rraghvani_0-1674741977316.png

The objects have two different parents i.e. browser

nedbacan
Frequent Contributor

 

Chrome 1 window

nedbacan_2-1674741277923.png

 

Chrome 2 window

nedbacan_3-1674741316974.png

 

nedbacan_4-1674742255532.png

 

 

rraghvani
Champion Level 2

See my previous response, screenshot and properties used to distinguish between the two browsers. 

 

I've defined two alias name mappings for each of the two browsers. You only have one alias name mapping!

cancel
Showing results for 
Search instead for 
Did you mean: