How to upload csv file to the website using katalon


#1

I want to upload .csv file to a website using Katalon. I’m using windows OS and read already raised topics related to this. but i couldn’t get a solution from those things without Robot framework. Please help me to resolve this.
this is my code part

WebUI.delay(3)
WebUI.uploadFile(findTestObject('Datalocker/Add-Dataset-Button'),'C:\\\\Users\\\\Rush\\\\Desktop\\\\AutomationFile\\\\Happy.csv')

readings


#2

The keyword WebUI.uploadFile, mentioned in your code is correct one to upload file.
Are you facing any error while using this keyword ?


#3

Hello @rushantha

You can use this custom keyword in every project project by creating the robot structure. I have worked hard and researched, but this was the best solution. Please take a look at the post below.


#4

Yes…file is not uploading and getting this kind of error


#5

Thanks @emine… I’ll try with your guidance tips


#6

If your issue isn’t solved already,
The attached image does not show complete stacktrace.
Could you paste the entire error message here ?


#7
06-21-2019 01:34:55 PM Test Cases/App/Datalocker/FileUpload/incompleteDatalocker_FileUploadSuccess

Elapsed time: 1m - 16.030s

Test Cases/App/Datalocker/FileUpload/incompleteDatalocker_FileUploadSuccess FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to upload file 'C:\\Users\\Rush\\Desktop\\AutomationFile\\Happy.csv' to object 'Object Repository/Datalocker/AddDataset' (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to upload file 'C:\\Users\\Rush\\Desktop\\AutomationFile\\Happy.csv' to object 'Object Repository/Datalocker/AddDataset'
	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:2945)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$uploadFile$8.call(Unknown Source)
	at incompleteDatalocker_FileUploadSuccess.run(incompleteDatalocker_FileUploadSuccess:20)
	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.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1561104293766.run(TempTestCase1561104293766.groovy:21)
Caused by: org.openqa.selenium.ElementNotInteractableException: Element <div id="add-data-set-fab-button" class="add-data-set-fab-button"> is not reachable by keyboard
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'DESKTOP-18SQV58', ip: '192.168.1.33', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: com.kms.katalon.core.webui.driver.firefox.CGeckoDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 66.0.5, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.23.0, moz:headless: false, moz:processID: 10648, moz:profile: C:\Users\Zepto\AppData\Loca..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, proxy: Proxy(direct), rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 15ae675e-dc97-4db5-af3d-585ecb9b3aad
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
	at com.kms.katalon.selenium.driver.CFirefoxDriver.execute(CFirefoxDriver.java:28)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
	at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:100)
	at com.kms.katalon.core.webui.keyword.builtin.UploadFileKeyword$_uploadFile_closure1.doCall(UploadFileKeyword.groovy:80)
	at com.kms.katalon.core.webui.keyword.builtin.UploadFileKeyword$_uploadFile_closure1.call(UploadFileKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	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:2945)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$uploadFile$8.call(Unknown Source)
	at Script1561097147817.run(Script1561097147817.groovy:20)
	... 11 more
)
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:39)
	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:2945)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$uploadFile$8.call(Unknown Source)
	at incompleteDatalocker_FileUploadSuccess.run(incompleteDatalocker_FileUploadSuccess:20)
	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.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1561104293766.run(TempTestCase1561104293766.groovy:21)
Caused by: com.kms.katalon.core.exception.StepFailedException: Unable to upload file 'C:\\Users\\Zepto\\Desktop\\AutomationFile\\Happy.csv' to object 'Object Repository/Datalocker/AddDataset'
	... 19 more
Caused by: org.openqa.selenium.ElementNotInteractableException: Element <div id="add-data-set-fab-button" class="add-data-set-fab-button"> is not reachable by keyboard
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'DESKTOP-18SQV58', ip: '192.168.1.33', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: com.kms.katalon.core.webui.driver.firefox.CGeckoDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 66.0.5, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.23.0, moz:headless: false, moz:processID: 10648, moz:profile: C:\Users\Zepto\AppData\Loca..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, proxy: Proxy(direct), rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 15ae675e-dc97-4db5-af3d-585ecb9b3aad
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
	at com.kms.katalon.selenium.driver.CFirefoxDriver.execute(CFirefoxDriver.java:28)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
	at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:100)
	at com.kms.katalon.core.webui.keyword.builtin.UploadFileKeyword$_uploadFile_closure1.doCall(UploadFileKeyword.groovy:80)
	at com.kms.katalon.core.webui.keyword.builtin.UploadFileKeyword$_uploadFile_closure1.call(UploadFileKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	... 17 more

#8

Please check your object property. As element is not intractable so you are getting this issue.
Use JavaScript executor to click on button.

Caused by: com.kms.katalon.core.exception.StepFailedException: Unable to upload file ‘C:\Users\Zepto\Desktop\AutomationFile\Happy.csv’ to object ‘Object Repository/Datalocker/AddDataset’
… 19 more
Caused by: org.openqa.selenium.ElementNotInteractableException: Element <div id=“add-data-set-fab-button” class=“add-data-set-fab-button”> is not reachable by keyboard


#9

Actually i couldn’t get you. sorry for that. how to use JavaScript executr for this purpose.


#10

WebUI.scrollToElement(findTestObject(’’), 20, FauilureHandling.OPTIONAL)
WebUI.uploadFile(findTestObject(), path)

if above not work then try to implement below code.

WebUI.executeJavaScript(‘document.getElementByid().click()’, [])
WebUI.setText(TestObject(), ‘Path’)
WebUI.submit()
–Root Cause - Object is not intractable so you need to handle this. ( either by object property, wait and Javascript executor