Run Chrome with a different user than the one who started Katalon


#1

Hello,

Actually, when I run a Test Suite in Katalon, it seems the web browser is started with the same user who started Katalon. In my company, we have to start Katalon with admin rights so Chrome is started with admin rights. But for proxy authentication reasons, the Web access are not the same compare to the normal user doing the test manually in the browser ( for example the Google APIs are not reachable ).

I tried ugly things with Keywords or Listerners starting Chrome with runas or psexec, it’s not working very well.

How can I change the Chrome settings to run it as the legacy user and not the admin user who started Katalon ?


#2

Try to experiment with user permissions for chromedriver.exe
Maybe this article will help you https://www.digitalcitizen.life/take-ownership-and-change-permissions-files-and-folders

Other way, you can write a bat file with following code: runas /user:Bob “chromedriver2.exe”
Convert that file from bat to exe, change name to chromedriver.exe and from now on Katalon probably will use this file to start chromedriver2.exe (original file)

Not sure if this will work, but you can try :wink:


#3

Thank you Mariusz for your reply, unfortunately it seems the settings for the chrome driver are not what could solved my problem.

I already test with the runas, but I have to type the password of the legacy user in the batch prompt and unfortunately it’s impossible to do it without a web browser opened. For example this is not working :

WebUI.sendKeys(null, “password”) // type the password
WebUI.sendKeys(null, Keys.chord(Keys.ENTER)) // valid the command prompt to start Chrome

I tested too the psexec downloaded from here : https://docs.microsoft.com/en-us/sysinternals/downloads/psexec

And with a command like this : psexec \computername -u domain\user -p password “chrome.exe”

But it’s not very proper and I have now a problem of password management inside the company.


#4

Or maybe you would run Katalon in a virtual machine?


#5

why do you need to run katalon with admin rights?
for me is running just fine as simple user


#6

In my company policies you’re not able to run software until you have a dedicated admin account.

I actually solved my problem by pushing Katalon on the white list of software of my company, it can be started with a normal user. And now chrome is started with the same user and the behaviour is ok.


#7

Any update on this?
I want to run the browser as different user for my testing.


#8

Hi, no update since I created the Topic.


#9

Thank you, so how you are doing your testing now.I could find .net impersonation code but not sure how that will work in katalon(groovy) if i do some modification .


#10

As a good user of Ranorex I tried the same approach, I tried to translate my C# code into Java / Groovy but I was not able to to something regarding the Policy of my company in term of security.

This is the workaround as described in my previous Post :

I actually solved my problem by pushing Katalon on the white list of software of my company, it can be started with a normal user. And now chrome is started with the same user and the behaviour is ok.


#11

Could you please copy the java/groovy code here.Thanks in advance


#12

As said before, my code to launch an external application ( from Katalon ) wasn’t really working due to the security policy of my company. I solved my problem by adding Katalon to the white list of my company and now I can launch it with a normal user then Chrome is started by the same way.

BTW if you’re looking for some Java code allowing you to start a process :

import java.io.*;
Process process = new ProcessBuilder("C:\\PathToExe\\MyExe.exe","param1","param2").start();

#13

Hi, Does anyone has any solution to run chrome as different user? If so how can we communicate that driver to user specific profile before opening the browser itself. Please suggest.


#14

Have a look at this post:


#15

Thanks for giving me reference to look at but still i’m facing some issues. Please have a look at below and correct me if i’m doing anything wrong.

Note: I’m working on Client machine where network access and permissions are very restricted.

Steps followed as per my requirement:

  1. I did run as different user on Chrome browser and logged in using profile with username as ‘test01’ and password as ‘xxxxx’
  2. It opened a new instance and once i hit the testing url again it opens a alert box to enter the profile credentials so after i enter them i can access the site with that specific profile.
  3. Below is the profile path displayed and required admin permission to access the folder ‘test01’
  4. Profile path mentioned in chrome://version: “C:\Users\test01\AppData\Local\Google\Chrome\User Data\Default”

Code written to use profile
// Copy the path to chromedriver.exe
String pathToChromeDriver = “C:\Automation\Katalon_Studio_Windows_64-5.9.1\configuration\resources\drivers\chromedriver_win32\chromedriver.exe”

System.setProperty(“webdriver.chrome.driver”, pathToChromeDriver)

//The below profile path is the one that got created when i did run as different user
String chromeProfilePath = “C:\Users\test01\AppData\Local\Google\Chrome\User Data\”;

//String chromeProfilePath = “C:\Users\myuser\AppData\Local\Google\Chrome\User Data\”; -->> I can only access profiles for default user ‘myuser’ folder

ChromeOptions chromeProfile = new ChromeOptions();

chromeProfile.addArguments("–no-sandbox");
chromeProfile.addArguments("–disable-extensions");
chromeProfile.addArguments(“start-maximized”);

chromeProfile.addArguments("–disable-popup-blocking");
chromeProfile.addArguments("–disable-dev-shm-usage")
chromeProfile.setExperimentalOption(“useAutomationExtension”, false)

chromeProfile.addArguments(“user-data-dir=” + chromeProfilePath);
// Here you specify the actual profile folder (Profile 2)
chromeProfile.addArguments(“profile-directory=Default”);

WebDriver driver = new ChromeDriver(chromeProfile);
driver.get(“https://xxxxxxx/lightning/page/home”);
DriverFactory.changeWebDriver(driver)

Below is the error which i’m facing:
2019-05-03 17:52:39.341 [1;31mERROR[0;39m [36mc.k.katalon.core.main.TestCaseExecutor -[0;39m [31m❌ driver = new org.openqa.selenium.chrome.ChromeDriver(chromeProfile) FAILED.[0;39m
[31mReason:[0;39m
[31morg.openqa.selenium.WebDriverException: unknown error: cannot create default profile directory[0;39m


#16

Sorry, I do not follow you. I do not see what you want to achieve.

Do you use Windows OS user named “test01” not not?

Have you created a Chrome profile named “myuser” or not?

Please distinguish Windows OS user and Chrome Profile. It seems you do not distinguish these 2 different concepts.


#17

If you have created Chrome profile “myuser” and logged into Chome with it, then you want to retrieve chrome://version page. The page will show you the path of the Profile. That would look something like the following screenshot
profile_path
The Profile Path would be something like

D:\Users\test01\AppData\Local\Google\Chrome\User Data\Profile N

where N would be 1, 2, 3, 4,… it is allocated by Chrome when “myuser” profile is created.

You need to find which “Profile N” is allocated for the Profile “myuser” by Chrome. — see the following post, where I explained how I solved the problem.


#18

@kazurayam
i think is opposite, his win user is ‘myuser’ and ‘test01’ the profile created :slight_smile: … but i can be wrong, it is not very clear where the OP is blocked
@Madhuri on short, the new chrome profile created should be found under the windows user path and have a name like ‘Profile N’, don’t use the Default one.


#19

Hi @kazurayam and @Ibus, sry for the confusion
Yes my window user is ‘myuser’ so if I create any profile its been under ‘myuser’ with ‘Profile N’. But I’m unable to use this for my scenario as its little different.

Scenario 1: Client has given access for QA environment for my window user i.e., ‘myuser’ but can test only few scenarios. Its just a login with SSO option hence its logs in automatically without any user credentials.

Scenario 2: Client has provided few user profiles which we should do run as different user in chrome and then access the QA for testing other scenarios

Here the problem is even if I create profiles and hit the QA url the login with different profile doesn’t work, it just has login with SSO button so it automatically logs me as ‘myuser’

I can login with different profile only when I do run as different user in chrome and detailed steps followed is mentioned in my previous post

When I run as different user with username ‘test01’ and observed the profile path as below:
“C:\Users\test01\AppData\Local\Google\Chrome\User Data\Default”
I saw the folder test01 created as per above path but i cannot access the folder items

Please suggest how to achieve the second scenario in this case.

Thanks!!


#21

mhm … for me looks like the ‘test01’ is also a windows user provided.
i have a strong feeling that your client make your life complicated because he feels that he must be in control.
for such cross user/profile/browser automated testing, in order to be relevant (aka repeatable results), imho browserstack is the right solution, not a single reused phisical machine
relevant testing implies certain abstractization. at this moment you are enforced to test using ‘another winuser credentials’ but without permissions on that account. this is a no go, virtualization to the rescue