Scripts runs on Windows server, but not through Jenkins

Hi,

I have an architecture Jenkins master - slave, where the master is Linux and the slave is Windows.
I have installed Katalon in the slave, and when I run my script from Katalon Studio, it works.

When I run the script from the Jenkins master, forcing it to be executed in the slave, it gives me an error when it gets to the javascript execution line:

ERROR c.k.k.core.keyword.internal.KeywordMain - ? Unable to execute JavaScript. (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to execute JavaScript.
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword.executeJavascript(ExecuteJavascriptKeyword.groovy:42)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword.execute(ExecuteJavascriptKeyword.groovy:37)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.executeJavaScript(WebUiBuiltInKeywords.groovy:3787)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$executeJavaScript$2.call(Unknown Source)

Caused by: org.openqa.selenium.JavascriptException: JavaScript error

Any help is welcome.

Is this issue resolved now? I encountered the similar issue when use JS to scrolldown:

String js = "document.getElementById('__xmlview4--structureTreeTableEdit-vsb').scrollTop=10000"

WebUI.click(findTestObject('Page_Configuration Cockpit/Create_Geolocation/span___xmlview4--idAddItemBtn-'))

'click first rowset for creating levels'
driver.findElement(By.xpath('//*[contains(@id,"structureTreeTableEdit-rowsel0")]')).click()

WebUI.waitForElementClickable(findTestObject('Page_Configuration Cockpit/Create_Geolocation/span___xmlview4--idAddItemBtn-'), 
    10)

WebUI.click(findTestObject('Page_Configuration Cockpit/Create_Geolocation/span___xmlview4--idAddItemBtn-'))

'scroll to the bottom'
WebUI.executeJavaScript(js, null)

Unfortunately, nobody answered yet to my post. Because it is a difficult integration issue, we will have to relay on the moderators or product integration experts to help us; or open a bug.

Is your architecture the same as mine? (Jenkins master Linux, Jenkins slave Windows, running on slave)

Update:

I was wondering if it was a security constraint/setting, so I created a new Windows desktop Jenkins slave node.
The test runs ok in Jenkins if I run the script on that computer.

Does anybody know what is the setting to be fiddled with in a Windows Server so katalon scripts containing javascript execution works ok?

Thanks in advance for your help and support.

Hi @spr2019, @xiaoqin.yu,

Please share us more info:

  • Which browser did the test run on?
  • The full strace-trace of the execution logs.

Thanks

Hi Duyluong,

Here are the details:

Katalon version: 6.2.1.2
Browser version: IE 11
IEDRIVERSERVER: 3.6.0.0 (I have tried as well 3.9.0.0, with the same results)

Other tests I have performed to refine the issue scope:

  • I have tried with Chrome and FF, and both work perfectly
  • I have created a Jenkins Windows desktop slave node, where I have installed the same scripts and Katalon Studio as I have in the Jenkins Windows server slave node. There, as well, the test runs perfectly from Jenkins.

So the only problem is when I try to execute in internet explorer 11, from a slave Jenkins in a Windows Server.

Just in case it helps, I can attach the difference between the IEDriverServer.log of the Windows server and the one of the Windows desktop:

WINDOWS SERVER (fails):

T 2019-08-14 15:27:50:841 server.cc(183) Process request with: URI: /session/c5dc20f2-5164-4f12-8622-1d37ad1699ff/execute/sync HTTP verb: POST
body: {
“script”: "localStorage.clear() ",
“args”: [
]
}
T 2019-08-14 15:27:50:841 server.cc(272) Entering Server::DispatchCommand
T 2019-08-14 15:27:50:841 server.cc(583) Entering Server::LookupCommand
D 2019-08-14 15:27:50:841 server.cc(281) Command: POST /session/c5dc20f2-5164-4f12-8622-1d37ad1699ff/execute/sync {
“script”: "localStorage.clear() ",
“args”: [
]
}
T 2019-08-14 15:27:50:841 server.cc(378) Entering Server::LookupSession
T 2019-08-14 15:27:50:841 IESession.cpp(191) Entering IESession::ExecuteCommand
T 2019-08-14 15:27:50:841 IECommandExecutor.cpp(125) Entering IECommandExecutor::OnSetCommand
T 2019-08-14 15:27:50:841 command.cc(31) Entering Command::Deserialize
D 2019-08-14 15:27:50:841 command.cc(36) Raw JSON command: { “name” : “executeScript”, “locator” : { “sessionid” : “c5dc20f2-5164-4f12-8622-1d37ad1699ff” }, “parameters” : {
“script”: "localStorage.clear() ",
“args”: [
]
} }
T 2019-08-14 15:27:50:841 IECommandExecutor.cpp(136) Entering IECommandExecutor::OnExecCommand
T 2019-08-14 15:27:50:841 IECommandExecutor.cpp(566) Entering IECommandExecutor::DispatchCommand
T 2019-08-14 15:27:50:841 IECommandExecutor.cpp(702) Entering IECommandExecutor::GetCurrentBrowser
T 2019-08-14 15:27:50:841 IECommandExecutor.cpp(708) Entering IECommandExecutor::GetManagedBrowser
T 2019-08-14 15:27:50:841 IECommandExecutor.cpp(654) Entering IECommandExecutor::IsAlertActive
T 2019-08-14 15:27:50:841 Browser.cpp(699) Entering Browser::GetActiveDialogWindowHandle
T 2019-08-14 15:27:50:841 Browser.cpp(205) Entering Browser::GetContentWindowHandle
D 2019-08-14 15:27:50:842 IECommandExecutor.cpp(668) No alert handle is found
T 2019-08-14 15:27:50:842 IECommandExecutor.cpp(702) Entering IECommandExecutor::GetCurrentBrowser
T 2019-08-14 15:27:50:842 IECommandExecutor.cpp(708) Entering IECommandExecutor::GetManagedBrowser
T 2019-08-14 15:27:50:842 Browser.cpp(125) Entering Browser::GetDocument
I 2019-08-14 15:27:50:842 Browser.cpp(129) No child frame focus. Focus is on top-level frame
T 2019-08-14 15:27:50:842 IESession.cpp(212) Beginning wait for response length to be not zero
T 2019-08-14 15:27:50:846 Browser.cpp(612) Entering Browser::GetDocumentFromWindow
T 2019-08-14 15:27:50:850 Script.cpp(60) Entering Script::Initialize
T 2019-08-14 15:27:50:850 Script.cpp(631) Entering Script::AddArguments
T 2019-08-14 15:27:50:850 Script.cpp(180) Entering Script::Execute
T 2019-08-14 15:27:50:850 Script.cpp(602) Entering Script::CreateAnonymousFunction
D 2019-08-14 15:27:50:857 Script.cpp(260) -2147352319 [Unknown error 0x80020101]: Failed to execute anonymous function, no exception information retrieved
T 2019-08-14 15:27:50:858 response.cc(91) Entering Response::SetErrorResponse
W 2019-08-14 15:27:50:858 response.cc(92) Error response has status code 17 and message ‘JavaScript error’ message
T 2019-08-14 15:27:50:858 response.cc(85) Entering Response::SetErrorResponse
T 2019-08-14 15:27:50:858 response.cc(78) Entering Response::SetResponse

WINDOWS DESKTOP (it works):

T 2019-08-14 09:59:51:085 server.cc(183) Process request with: URI: /session/9a421ef6-02a9-4934-a248-b319c7c61cd4/execute/sync HTTP verb: POST
body: {
“script”: “localStorage.clear()”,
“args”: [
]
}
T 2019-08-14 09:59:51:085 server.cc(272) Entering Server::DispatchCommand
T 2019-08-14 09:59:51:085 server.cc(583) Entering Server::LookupCommand
D 2019-08-14 09:59:51:085 server.cc(281) Command: POST /session/9a421ef6-02a9-4934-a248-b319c7c61cd4/execute/sync {
“script”: “localStorage.clear()”,
“args”: [
]
}
T 2019-08-14 09:59:51:088 server.cc(378) Entering Server::LookupSession
T 2019-08-14 09:59:51:088 IESession.cpp(191) Entering IESession::ExecuteCommand
T 2019-08-14 09:59:51:089 IECommandExecutor.cpp(122) Entering IECommandExecutor::OnSetCommand
T 2019-08-14 09:59:51:089 command.cc(31) Entering Command::Deserialize
D 2019-08-14 09:59:51:089 command.cc(36) Raw JSON command: { “name” : “executeScript”, “locator” : { “sessionid” : “9a421ef6-02a9-4934-a248-b319c7c61cd4” }, “parameters” : {
“script”: “localStorage.clear()”,
“args”: [
]
} }
T 2019-08-14 09:59:51:089 IECommandExecutor.cpp(133) Entering IECommandExecutor::OnExecCommand
T 2019-08-14 09:59:51:089 IECommandExecutor.cpp(454) Entering IECommandExecutor::DispatchCommand
T 2019-08-14 09:59:51:089 IECommandExecutor.cpp(577) Entering IECommandExecutor::GetCurrentBrowser
T 2019-08-14 09:59:51:089 IECommandExecutor.cpp(583) Entering IECommandExecutor::GetManagedBrowser
T 2019-08-14 09:59:51:089 IECommandExecutor.cpp(529) Entering IECommandExecutor::IsAlertActive
T 2019-08-14 09:59:51:089 Browser.cpp(700) Entering Browser::GetActiveDialogWindowHandle
T 2019-08-14 09:59:51:089 Browser.cpp(206) Entering Browser::GetContentWindowHandle
D 2019-08-14 09:59:51:093 IECommandExecutor.cpp(543) No alert handle is found
T 2019-08-14 09:59:51:094 IECommandExecutor.cpp(577) Entering IECommandExecutor::GetCurrentBrowser
T 2019-08-14 09:59:51:094 IECommandExecutor.cpp(583) Entering IECommandExecutor::GetManagedBrowser
T 2019-08-14 09:59:51:094 Browser.cpp(126) Entering Browser::GetDocument
I 2019-08-14 09:59:51:094 Browser.cpp(130) No child frame focus. Focus is on top-level frame
T 2019-08-14 09:59:51:094 IESession.cpp(212) Beginning wait for response length to be not zero
T 2019-08-14 09:59:51:912 Browser.cpp(613) Entering Browser::GetDocumentFromWindow
T 2019-08-14 09:59:51:917 Script.cpp(49) Entering Script::Initialize
T 2019-08-14 09:59:51:917 CommandHandlers\ExecuteScriptCommandHandler.cpp(85) Entering ExecuteScriptCommandHandler::PopulateArgumentArray
T 2019-08-14 09:59:51:917 Script.cpp(169) Entering Script::Execute
T 2019-08-14 09:59:51:917 Script.cpp(438) Entering Script::CreateAnonymousFunction
T 2019-08-14 09:59:51:952 Script.cpp(426) Entering Script::ConvertResultToJsonValue
T 2019-08-14 09:59:51:952 response.cc(72) Entering Response::SetSuccessResponse
T 2019-08-14 09:59:51:952 response.cc(78) Entering Response::SetResponse

You can see clearly that the instruction Script.cpp(602) Entering Script::CreateAnonymousFunction
is well handled in Windows desktop, but not in Windows Server.

As well, I provide the Jenkins log (failed job on Windows server):

2019-08-13 14:46:32.531 ERROR c.k.k.core.keyword.internal.KeywordMain - ? Unable to execute JavaScript. (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to execute JavaScript.
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword.executeJavascript(ExecuteJavascriptKeyword.groovy:42)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword.execute(ExecuteJavascriptKeyword.groovy:37)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.executeJavaScript(WebUiBuiltInKeywords.groovy:3787)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$executeJavaScript$2.call(Unknown Source)
at create new client.run(create new client:25)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:133)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:116)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:83)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1565700365710.run(TempTestSuite1565700365710.groovy:35)
Caused by: org.openqa.selenium.JavascriptException: JavaScript error
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ABCDEFG-01’, ip: ‘00.11.22.197’, os.name: ‘Windows Server 2016’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CInternetExplorerDriver
Capabilities {acceptInsecureCerts: false, browserName: internet explorer, browserVersion: 11, javascriptEnabled: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, se:ieOptions:

{browserAttachTimeout: 0, elementScrollBehavior: 0, enablePersistentHover: true, ie.browserCommandLineSwitches: , ie.ensureCleanSession: true, ie.fileUploadDialogTimeout: 3000, ie.forceCreateProcessApi: false, ignoreProtectedModeSettings: true, ignoreZoomSetting: false, initialBrowserUrl: http://localhost:22216/, nativeEvents: true, requireWindowFocus: false}

, setWindowRect: true}

Thanks for your help and support.

@spr2019,

  • Did you enable JavaScript of IE on the Windows Server machine?

  • How about if your run the JavaScript query manually on IE browser of the Windows Server machine?

  • Run Katalon test directly on Windows Server machine, what is the Script result?

Thanks

@duyluong,

Hi,
JavaScript is enabled in Windows Server. If I executed via Katalon Studio, it works fine. The problem is when I execute it from Jenkins.

If I run the localStorage.clear() instruction from the IE console, the result is correct.

Hi @spr2019,

If the issue comes from Jenkins slave, you may try to run Jenkins as a process “java -jar jenkin.war”, not as a service on your Windows Server machine.

Thanks

1 Like

Hi Duyluong,

Yes there is a bug that makes Jenkins slave not working with Katalon if it is started via a windows service.
I opened a bug in Jenkins, but I think is to Katalon to adapt to the new Jenkins security policy.

As you knew the issue, even when I didn’t say that I was running a service, I suppose this bug is known, but I couldn’t find it in the Jira bugs.

Is it something that it’s being corrected for next Katalon releases?

This has a Windows Server security smell. What account is the service using? Is it the same account that Jenkins is using?

At a guess, I’d want Jenkins, IE and the service to be executed in the same security context/account.

I believe you are correct about the Windows security. I couldn’t run a Jenkins job via the Jenkins service using the system account. I changed it to my own account and apparently it liked the security settings and allowed the job to execute.

Another issue was while monitoring the job, I could see it interacting with web pages correctly although the web pages were not displaying on the Windows display. I monitored the Windows Task Manager and I could see the chromedriver.exe and additional chrome.exe processes coming and going. The script was getting near the end and it was not able to locate a specific element on the web page and the job failed. When I stopped the Windows service and ran the Jenkins Agent as a process, the job runs fine and also displays the entire process on the Windows display.

Thus, I’m sure there is some other configuration which would enable the service to work, but I’m not sure what that might be. If anyone knows, please reply.

Thanks,
John