WebUI uploadFile failed

I try to use WebUI uploadFile keyword but can’t make it work.

For example, my testObject is ‘Configuration/Client/div_insert_photo’

On my script, I verify the testObject by:
WebUI.verifyElementPresent(findTestObject(‘Configuration/Client/div_insert_photo’), 2)
or
text = WebUI.getText(findTestObject(‘Configuration/Client/div_insert_photo’))
or even click on the object, this will bring the browser to choose the file for uploading
WebUI.click(findTestObject(‘Configuration/Client/div_insert_photo’))

But it always failed when I try to to use uploadFile keyword to this testObject:
WebUI.uploadFile(findTestObject(‘Configuration/Client/div_insert_photo’), ‘/Users/[myhome]/resources/data/desktop.jpg’, _
_ FailureHandling.CONTINUE_ON_FAILURE)

or also failed with sendKeys keyword
WebUI.sendKeys(findTestObject(‘Configuration/Client/div_insert_photo’), ‘/Users/[myhome]/resources/data/desktop.jpg’, _
_ FailureHandling.CONTINUE_ON_FAILURE)

with error:

2019-09-30 10:52:55.783 DEBUG M-104 Client Configuration - Upload Logo - 9: uploadFile(findTestObject(“Configuration/Client/div_insert_photo”), “/Users/[myhome]/resources/data/desktop.jpg”, CONTINUE_ON_FAILURE)

2019-09-30 10:52:56.273 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to upload file ‘/Users/[myhome]/resources/data/desktop.jpg’ to object ‘Object Repository/Configuration/Client/div_insert_photo’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to upload file ‘/Users/[myhome]/resources/data/desktop.jpg’ to object ‘Object Repository/Configuration/Client/div_insert_photo’

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.UploadFileKeyword.uploadFile(UploadFileKeyword.groovy:87)

at com.kms.katalon.core.webui.keyword.builtin.UploadFileKeyword.execute(UploadFileKeyword.groovy:68)

at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.uploadFile(WebUiBuiltInKeywords.groovy:2931)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$uploadFile$2.call(Unknown Source)

at Client Configuration - Upload Logo.run(Client Configuration - Upload Logo:33)

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.RawTestScriptExecutor.runScript(RawTestScriptExecutor.java:34)

at com.kms.katalon.core.main.RawTestScriptExecutor.doExecute(RawTestScriptExecutor.java:29)

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.TestCaseMain.runTestCaseRawScript(TestCaseMain.java:151)

at com.kms.katalon.core.main.TestCaseMain$runTestCaseRawScript$0.call(Unknown Source)

at TempTestCase1569865969245.run(TempTestCase1569865969245.groovy:64)

Caused by: org.openqa.selenium.ElementNotInteractableException: element not interactable

(Session info: chrome=77.0.3865.90)

Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’

System info: host: ‘MY-MAC’, ip: ‘xxxxxx%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.14.6’, java.version: ‘1.8.0_181’

Driver info: com.kms.katalon.core.webui.driver.ExistingRemoteWebDriver

If anyone has any idea about this error? thank much in advance

What is the type (HTML tag) of this object Configuration/Client/div_insert_photo?

Hello @hinpham

Please you can look below link.

1 Like

Hi @devalex88
Look like type is “div”, here is the completed element:

<div class="mdl-card__title mdl-card--expand" onclick="showFilePopup('desktop')" ondragend="onOtherDragEvents(event,'desktop')" ondragenter="onOtherDragEvents(event,'desktop')" ondragleave="onImageDragLeft(event,'desktop')" ondragover="onImageDragOver(event,'desktop')" ondragstart="onOtherDragEvents(event,'desktop')" ondrop="onImageDrop(event,'desktop')" style="cursor: pointer;">
    <i class="material-icons mdl-color-text--green-200" style="font-size: 100px; text-align: center; margin-left: auto; margin-right: auto;">insert_photo</i>
</div>

hi @ emine, thank much for your tip!
I followed your steps to create my own customer keywork hpPK.hpKW.uploadFile. it does get called in the script, and does the “WebUI.click(to)” to bring up the file brower, but nothing else happens there…

On Log Viewer, it shows:
10-01-2019 04:49:35 PM hpPK.hpKW.uploadFile(findTestObject(“Configuration/Client/div_insert_photo”), “/Users[myhome]/bam2/desktop.png”)
Elapsed time: 4.069s
hpPK.hpKW.uploadFile is PASSED

But on Console log, seeing a bundle of warnings and errors like:
2019-10-01 17:05:02.209 INFO c.k.k.core.webui.driver.DriverFactory - Starting ‘Chrome’ driver
Oct 01, 2019 5:05:02 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
2019-10-01 17:05:02.234 INFO c.k.k.core.webui.driver.DriverFactory - Action delay is set to 0 seconds
Starting ChromeDriver 76.0.3809.68 (420c9498db8ce8fcd190a954d51297672c1515d5-refs/branch-heads/3809@{#864}) on port 7992
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1569974704.022][WARNING]: This version of ChromeDriver has not been tested with Chrome version 77.
Oct 01, 2019 5:05:04 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
2019-10-01 17:05:04.211 INFO c.k.k.core.webui.driver.DriverFactory - sessionId = a99d0a4e4927b67b95b5386dc96ba416

2019-10-01 16:49:35.943 DEBUG M-104 Client Configuration - Upload Logo - 6: hpPK.hpKW.uploadFile(findTestObject(“Configuration/Client/div_insert_photo”), “/Users/[myhome]/bam2/desktop.png”)
2019-10-01 16:49:39.992 java[58271:1379835] pid(58271)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-10-01 16:49:39.992 java[58271:1379835] pid(58271)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-10-01 16:49:39.992 java[58271:1379835] pid(58271)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-10-01 16:49:40.011 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - hpPK.hpKW.uploadFile is PASSED
2019-10-01 16:49:40.012 DEBUG M-104 Client Configuration - Upload Logo - 7: Thread.sleep(3000)

Any idea what i’m missing? thanks

Hello Again @hinpham
For parameters (Configuration/Client/div_insert_photo”), “/Users[myhome]/bam2/desktop.png”) , the first parameter, Configuration/Client/div_insert_photo” ,must be the area you click on.
When defining the file path in the second parameter, /Users[myhome]/bam2/desktop.png, please define using not only \ \ eg. C: \\users \\ file \\ test.png

hi @emine, thanks for quick response.
When calling my custom keyword hpPK.hpKW.uploadFile(findTestObject(“Configuration/Client/div_insert_photo”), “/Users/pham/bam2/desktop.png”)
I do see the the area has been clicked on by the code “WebUI.click(to)” inside the custom keyword public class (to bring the file brower up just like I manually click on the area), so the first parameter seems correct.
For the second parameter: my script is running on mac OS X, “/Users/pham/bam2/desktop.png” is a valid path, so i have tried /Users/pham/bam2/desktop.png or //Users//pham//bam2//desktop.png but nothing works.