Getting chromedriver.log when you run Record/Spy Web to investigate why KS failed to start Chrome


#1

# Background

In the Katalon Forum you can find many posts where people had problem activating Google Chrome browser from Katalon Studio. In most cases the discussion tends to fall unproductive due to lack of enough information(diagnostic) what’s going on between Katalon Studio and Chrome browser.

- https://forum.katalon.com/discussion/6715/unable-to-launch-test-suite-with-chrome-66-0-3359-170-64-bits

- https://forum.katalon.com/discussion/6656/running-playback-of-test-cases-in-chrome-not-working-but-spy-record-works

- https://forum.katalon.com/discussion/4764/unable-to-open-browser-with-url

- https://forum.katalon.com/discussion/4131/record-web-browser-binaries-not-found

- https://forum.katalon.com/discussion/comment/15220#Comment_15220

- https://forum.katalon.com/discussion/4829/unknown-error-cannot-find-chrome-binary

- https://forum.katalon.com/discussion/6150/google-chrome-crashed-on-my-pc-----2-reasons-found
and more…

# chromedriver.log file

Katalon Studio executes the [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/) in order to open Google Chrome browser. Chromedriver can write logs. The [documentation](https://sites.google.com/a/chromium.org/chromedriver/logging) tells you how to enable chromedriver logging.

Let me show you a fragment of a chromedirver.log file here: this shows the command line to start chrome.exe. In other words you can see in detail how Katalon Studio tried to start and communicate with the Chrome browser:

[1526012674.637][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --ignore-certificate-errors --load-extension="C:\Katalon_Studio_Windows_64-5.4.1\configuration\resources\extensions\Chrome\Object Spy,C:\Users\username\AppData\Local\Temp\scoped_dir10832_12653\internal" --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12067 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\username\AppData\Local\Temp\scoped_dir10832_25782" data:,

Please find a example chromedriver.log file attached to this post where you can find what level of detail is available.

# Problem to solve

If I want to get chromedriver.log when I run a Test Case, I can enable chromedriver’s logging feature by setting JVM System Property `webdriver.chrome.logfile` as follows:

System.setProperty('webdriver.chrome.logfile', "C:/temp/chromedriver_TC1.log")
WebUI.openBrowser('')
// execute some steps
WebUI.navigateToUrl('http://demoaut.katalon.com')
WebUI.verifyElementPresent(findTestObject("Page_CURA Healthcare Service/a_Make Appointment"), 20)
// close the browser
WebUI.closeBrowser()

Provided with this level of detail diagnostics, the discussions in the Katalon Forum regarding failures around Chrome browser could be more productive.

OK, this works fine when I run a Test Case.

However, how can I get the chromedriver.log file when I use the Record/Spy Web features? Because in Record/Spy Web, I have no chance to write Groovy script to set Java VM System Property.

# Solution

In the directory where you installed the Katalon Studio, you will find a file named `katalon.ini`. In this file a few arguments are written which are passed to the Java VM for the Katalon Studio. I tried sightly modify the `katalon.ini` as follows:

In the %KATALON\_STUDIO\_INSTALLED_FOLDER%\\katalon.ini

-startup
plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.401.v20161122-1740
-data
config
-vmargs
-Xms256m
-Xmx4048m
-Dwebdriver.chrome.logfile=C:/temp/chromedriver.log

Please note the very last line above. With -D argument I could specify a JVM System Property `webdriver.chrome.logfile` which is effective even when I run the Record/Spy Web features.

This worked fine for me. I could get chromedriver.log file for Record/Spy Web as well as Test Cases.

# Please bear it in mind that …

The `katalon.ini` file seems to be very fragile. If you make any mistake in `katalon.ini`, unpredictable erros may occur. For example, I experienced a problem when I wrote as follows:

-Dwebdriver.chrome.logfile="C:/temp/chromedriver.log"

Beware, the double quotations around the file path made katalon.exe crasy.

Also you should be aware that the Katalon Official document does not cover ‘katalon.ini’ file. Presumably they do not like users to touch this at all. This is why I put this post into the “tricks” category :stuck_out_tongue: .

Hope this helps.

chromedriver.log


Running Chrome from Katalon (Linux)
I can not start Chrome from Katalon.
Chrome issue: Unable to launch the web browser
#2

Append the following line to the katalon.ini file,

-Dwebdriver.firefox.logfile=C:/temp/firefoxdriver.log

then you will get the log how Katalon Studio tried to start and communicate with Firefox browser.


#3

Correction:

I tried appending “-Dwebdriver.firefox.logfile=C:/temp/firefoxdriver.log” to katalon.ini. It seems not working now. Curious. I seem to remember it worked for me last friday. But not now …


#4

One more correction:

I changed my %KATALON\_STUDIO\_INSTALLED_FOLDER%\\katalon.ini file as follows:

-startup
plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.401.v20161122-1740
-data
config
-vmargs
-Xms256m
-Xmx4048m
-Dwebdriver.chrome.logfile=C:/temp/chromedriver.log
-Dwebdriver.firefox.logfile=C:/temp/firefoxdriver.log

And in the command line I did the following:

$ cd %KATALON_STUDIO_INSTALLED_FOLDER%
$ eclipsec.exe -clean

A window of Katalon Studio opened. Soon I closed it. Then, I started Katalon Studio as usual (by clicking desktop icons etc).

I did Record/Web Spy/Run TestCase using Chrome browser.
I got C:/temp/chromedriver.log file.
I did Record/Web Spy/Run TestCase using Firefox Browser.
I got C:/temp/firefoxdriver.log file as well.

“$ eclipsec.exe -clean” operation is necessary in order to clean the internal cache of Eclipse, and make my change in the katalon.ini file effective.


#5

I want to confirm if the system properties I specified in the katalon.ini file are really accepted by Katalon Studio. How can I check it? ---- Katalon Studio provides enough tools. Let me show you how.

In the tool bar of Katalon Studio, you want to navigate Help > About.

Dialog “About Katalon Studio” appears.

Click “Installation Details” button. Then Another dialog “Katalon Studio Installation Details” appears.

In this dialog, System properties acknowledged by Katalon Studio are listed. The list includes lines I specified in the katalon.ini file.

In the above screenshot you can see I put the following lines in the katalon.ini file:

-Dwebdriver.chrome.logfile=C:/temp/chromedriver.log
-Dwebdriver.firefox.logfile=C:/temp/firefoxdriver.log
-Dhttp.proxyHost=172.24.2.10
-Dhttp.proxyPort=8080
-Dhttps.proxyHost=172.24.2.10
-Dhttps.proxyPort=8080

In the “Katalon Studio Installation Details” dialog you find a button “View Error Log”. By clicking this button you can see the log of Katalon Studio.

I happened to find an interesting message in the Katalon Studio log.

!MESSAGE System property http.proxyHost has been set to 172.24.2.10 by an external source. This value will be overwritten using the values from the preferences

This means that the system property “http.proxyHost” which I specified in the katalon.ini file was once read, but it will be overritten using the values from the “Katalon Studio Preferences > Proxy”. Well, well, …

Help_About.png

InstallationDetails.png

ConfigurationDetails.png

ConfigurationDetails_2.png

http.proxyHostWillBeOverwritten.png


#6

@@4280-kazurayam, do you have an idea on how to configure the same (browser log file creation), but for Remote execution, not for local execution.
Means the problem is if I set the path as “C:/browser_logs/chrome.log” the script interprets is as a local machine folder and will write the log only if browser instance is created on a LOCAL machine.
That’s my understanding.


#7

do you have an idea on how to configure the same (browser log file creation), but for Remote execution, not for local execution.

If you are running the remote sever for yourslef and you can log into the Remote Selenium server with high-profiled user, then you should be able to read the log on the remote machine with ssh/scp commands.

Do you want to get access to the webdriver’s log on a Remote Selenium Server using Katalon Stuido’s test case script? I am negative. I think that the Selenium WebDriver API does not support feature of transporting the remote drivers’ log to the WebDrvier clients.


#8

As for Remote Driver, the following post might be interesting for you:


#9

@kazurayam
I was playing with your git test project to familiarize myself with some of the features I’ve been curious about.

My question is where does Katalon specify the location of Chromedriver - or is it expecting some default location?

I am getting :
05-10-2019 03:48:57 PM Test Cases/Login Test Case

Elapsed time: 1.015s

Test Cases/Login Test Case FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to open browser with url: ’ ’
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64) . . . . .
I tried to turn on logging with a system.setproperty(“Prop”,“val”) like you specified and I get no joy. No records get written to the logger. Let me know if you have any pointers


#10

On my Mac,
/Applications/Katalon Studio.app/Contents/Eclipse/configuration/resources/drivers/chromedriver_mac/chromedriver

On Windows, you can find the directory named configuration in the directory where you deployed the distributable of Katalon Studio.

Please read the implementation code of getChromeDriverPath() method of the com.kazurayam.webdriverfactory4ks.ChromeDriverFactory class
https://github.com/kazurayam/webdriverfactory4ks/blob/master/Keywords/com/kazurayam/webdriverfactory4ks/ChromeDriverFactory.groovy line#240


#11

The code of com.kazurayam.webdriverfactory4ks.ApplicationInfo class at https://github.com/kazurayam/webdriverfactory4ks/blob/master/Keywords/com/kazurayam/webdriverfactory4ks/ApplicationInfo.groovy will show you the following.

On Windows, you will find %HOME%.katalon\application.properties file. In the file, the first line would be, for example:

#C:\Katalon_Studio_Windows_64-5.10.1

This denotes where you deployed the distributable of Katalon Studio.

On Mac, Katalon Studio’s app will be deployed at /Applications/Katalon Studio.app. This path is fixed.


Please be aware I am not a member of Katalon developers. I don’t know the spec. I just found the above facts. I could be wrong. Don’t blame me.


#12

Yeah I found the location of the Katalon folder, I just didn’t know it expected Chromedriver to be in the drivers folder. I have Chrome driver for my IntelliJ configuration and I want to simply point Katalon to my Chromedriver in my IntelliJ deployment instead of having a duplicate copy in Katalon. Let me know if you know where to specify the location, I think I saw another of your posts where you added some start-up preferences to Katalon. I’m gonna look for it and see if I can rig it to simply pick my current setting. If all else fails I’ll dump another copy in the Katalon\drivers folder. And I understand you are not part of the Katalon Dev team, am cool. You’ve demonstrated better comprehension of the architecture than me and thats enough. Thanks again.


#13

OK.

See line#107-108 of https://github.com/kazurayam/webdriverfactory4ks/blob/master/Keywords/com/kazurayam/webdriverfactory4ks/ChromeDriverFactory.groovy

You can do this:

import java.nio.file.Path
import java.nio.file.Paths
...
Path chromeDriverPath = Paths.get("path of chrome driver for your IntelliJ configuration")
System.setProperty('webdriver.chrome.driver', chromeDriverPath.toString())

#14

Perfect homie! And a simple solution as always. I was looking to hoist the request during setup/initialization but this works for the majority of my concerns.