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
Marsha_R
Community Hero

If this is something that Chrome allows you to do in a manual test, then you should just do a recording and walk through the steps that you need to use.

 

TestComplete will allow multiple tabs and moving between them but I don't know if Chrome lets you be logged in with two different users at the same time.

 

I'm curious - what's your user story that has two users logged in on the same machine at the same time?


Marsha_R
[Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
nedbacan
Frequent Contributor

Yes, Chrome allows two browsers to be opened using different profiles.

 

In my manual test, I open two Chrome windows using two user profile. 

The reason I do this is to be able to log on different users to the web app being tested without having to go on to another computer to launch the web app for the 2nd user.

 

I would like to know what method I need to use to open two instances of Chrome with different user profile.

 

I just wonder if this is not a situation that would happen in real usage of the product.

 

In any case, I would still do it with a recording. You can record in either keyword test mode or script test mode and walk through the manual steps and that will give you the code you need.


Marsha_R
[Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
tvklovesu
Contributor

You can do that using the chrome capabilities while launching the browser

{
"goog:chromeOptions": {
"args": [
"user-data-dir=C:/Users/{username}/Desktop/User Data",
"profile-directory=Profile 2"
]
}

.

But the issue here would be the complete E2E test should be in same keyword test. So TC will treat it as one test case and run the steps.

nedbacan
Frequent Contributor

Hello.  I am trying to learn how to launch Chrome with a profile user, which in this case will be 2.  But the program ends with an error  ..... " The process "browser" does not exist."

  I checked the chrome is in the Object Browser.  Can someone give me more detail on overcoming this error, I was reading something about creating an alias for it, but I am not familiar with this. 

Thank you.

 

 

function LaunchChromeWithProfile2() {
// Get the path to the Chrome executable
var chromePath = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
// Get the path to the "Profile 2" profile
var profilePath = "C:\\Users\\username\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2";
  
// Launch Chrome with the "Profile 2" profile
Aliases.browser.Run(chromePath, "--user-data-dir=" + profilePath);

}

 

 

Hi,

 

Aliases.browser references the already running application. You are getting error because Chrome is not running at this moment.

I would suggest to resort to the .RunOptions property of the BrowserInfo object (https://support.smartbear.com/testcomplete/docs/reference/test-objects/controls/web/general/browseri...) to start the browser.

Hope the example will help.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
nedbacan
Frequent Contributor

Using Test Complete, no matter if in Keyword or Script, Can I open two Chrome Windows under different user profiles and run an automation test to jump between windows to check a few states on the GUI of each window called. 

 

The reason of my question,

I have two Chrome sessions open, Chrome (profiler1) and (profiler2) in order to log on to the application as different user; as "admin" and "user1" from the same desktop.

When user1 performs an action on Chrome profile 2, I need to verify "admin" receives the request of user1 without having to log off and back on. 

Both users must be logged on in order to see the event happen or get certain buttons or links enabled.

 

Right now, that scenario is being done manually and it's time-consuming/

 

Any other thoughts how this can be done using Test Complete?

rraghvani
Valued Contributor

This would not work for me,

 

function SetChromeRunOptions()
{
    var URL = "https://www.w3schools.com/html/default.asp";
    Browsers.Item("chrome").RunOptions = "--user-data-dir=C:\\Temp\\User1";
    Browsers.Item("chrome").Run(URL);

    var URL = "https://www.w3schools.com/js/default.asp";
    Browsers.Item("chrome").RunOptions = "--user-data-dir=C:\\Temp\\User2";
    Browsers.Item("chrome").Run(URL);
}

 

However, if I use TestedApps then it works fine,

 

function Chromes()
{
    var chrome1 = TestedApps.chrome1.Run();
    var chrome2 = TestedApps.chrome2.Run();
}

 

rraghvani_1-1674645446044.png

 

 

rraghvani_0-1674645336386.png

 

nedbacan
Frequent Contributor

Thanks for your response. Sorry, but can you explain in detail how this function works or if you can show step by step. 

 

It returns an error, "TestedApps not defined".   Sorry, I am not well-versed in declaring functions

function Chromes()
{
    var chrome1 = TestedApps.chrome1.Run();
    var chrome2 = TestedApps.chrome2.Run();
}

 

 

 

cancel
Showing results for 
Search instead for 
Did you mean: