Need help to paste the image

I need to paste the image copied directly from the snipping tool. The html code shows the iframe for the box where I need to paste as as below.

After switching to iframe, I tried to paste the stored image using webelement- upload file and send keys. This all wrote the path of the stored image instead pasting it.

Pls guide me how can I paste in the given box area?

How about using the Robot to paste? Note you cannot be playing around with your mouse or keyboard at the same time as the Robot is running. If you are, then the Robot will lose focus on the canvas you want to paste on.

import java.awt.Robot
import java.awt.event.KeyEvent

WebUI.click(findTestObject(...)

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);

WebUI.delay(2)

@grylion54 I applied above script. But it shows error below from step 18 onwards.

2021-10-08 15:31:52.825 DEBUG testcase.test result 2 - 14: switchToFrame(findTestObject(“test result 2/iframe_add result description”), 2)
2021-10-08 15:31:53.380 DEBUG testcase.test result 2 - 15: click(findTestObject(“Test procedure/iframe_body”))
2021-10-08 15:31:53.474 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed to find element with id ‘Object Repository/Test procedure/iframe_body’. Try using Self-healing.
2021-10-08 15:31:53.556 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] The current locator of test object ‘Object Repository/Test procedure/iframe_body’ was broken. Propose an alternative one: ‘//html/body’.
2021-10-08 15:31:53.648 DEBUG testcase.test result 2 - 16: setText(findTestObject(“Test procedure/iframe_body”), “test result is done”)
2021-10-08 15:31:53.743 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed to find element with id ‘Object Repository/Test procedure/iframe_body’. Try using Self-healing.
2021-10-08 15:31:53.782 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] The current locator of test object ‘Object Repository/Test procedure/iframe_body’ was broken. Propose an alternative one: ‘//html/body’.
2021-10-08 15:31:53.833 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed to find element with id ‘Object Repository/Test procedure/iframe_body’. Try using Self-healing.
2021-10-08 15:31:53.861 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] The current locator of test object ‘Object Repository/Test procedure/iframe_body’ was broken. Propose an alternative one: ‘//html/body’.
2021-10-08 15:31:53.950 DEBUG testcase.test result 2 - 17: switchToDefaultContent()
2021-10-08 15:31:53.998 DEBUG testcase.test result 2 - 18: switchToFrame(findTestObject(“test result 2/Page_Test Procedure 0221/iframe_sc upload”), 2)
2021-10-08 15:31:54.389 DEBUG testcase.test result 2 - 19: click(findTestObject(“Test plan enteris/iframe_Body”))
2021-10-08 15:31:54.609 DEBUG testcase.test result 2 - 20: robot = new java.awt.Robot()
2021-10-08 15:31:54.750 DEBUG testcase.test result 2 - 21: robot.keyPress(VK_CONTROL)
2021-10-08 15:31:54.790 DEBUG testcase.test result 2 - 22: robot.keyPress(VK_V)
2021-10-08 15:31:54.791 DEBUG testcase.test result 2 - 23: robot.keyRelease(VK_V)
2021-10-08 15:31:54.792 DEBUG testcase.test result 2 - 24: robot.keyRelease(VK_CONTROL)
2021-10-08 15:31:54.792 DEBUG testcase.test result 2 - 25: WebUT.delay(2)
2021-10-08 15:31:54.792 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/UT-533/test result 2 FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: WebUT for class: Script1633442881093

what should I keep in findtestobject as it is under ifame. Also do I have to keep open snipping tool open for robot?

It seems you have a spelling mistake in the statement:

WebUT.delay(2)

It should be WebUI instead of WebUT.

As for your <iframe> issue:
https://docs.katalon.com/katalon-studio/docs/handling_iframe_issue.html#usage-example-3-switch-to-frame

Hi @grylion54. Thanks, spell mistake has been corrected. Although, no image is pasted when executed. Pls check my script above from step 17. let me know if I made any mistake.

Don’t see one. Do you get an image to paste if you do the process manually using, CTRL + V?

@grylion54. if i keep open my snipping tool, I have to manually press. Now it is working for me when minimize it. Thank you so much.

You can do it manually if you cannot get the paste to work, however, CTRL + V done by robot should work. I use it regularly. I can suggest:

  1. can you do a setText on the canvas to ensure you are clicking on it (and it is the correct element)?

  2. perhaps you can add an <Enter> to the robot to simulate bringing focus to the canvas:

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
1 Like

@grylion54 Hi there, I have again issue with uploading image but at different place.
Now I am trying to upload from the folder where I need to select the image. I tried with uploadfiles , looks it’s passed but the image is not uploaded. please check below error.

2021-10-15 13:20:47.023 DEBUG testcase.test result 2 - 32: click(findTestObject(“test result 2/Page_Test Procedure 0221/span_Upload Files”))
2021-10-15 13:20:47.489 DEBUG testcase.test result 2 - 33: sendKeys(findTestObject(“test result 2/Page_Test Procedure 0221/input_File select”), file)
2021-10-15 13:20:47.490 WARN testcase.test result 2 - SKIPPED NOT_RUN: sendKeys(findTestObject(“test result 2/Page_Test Procedure 0221/input_File select”), file)
2021-10-15 13:20:47.490 DEBUG testcase.test result 2 - 34: uploadFile(findTestObject(“test result 2/Page_Test Procedure 0221/input_File select”), “C:\Users\KParekh\Katalon studio guide\Ktalaon xpath sc\Add_FRS.png”)
2021-10-15 13:20:48.748 DEBUG testcase.test result 2 - 35: click(findTestObject(“test result 2/Page_Test Procedure 0221/input_File select”))
2021-10-15 13:20:48.749 WARN testcase.test result 2 - SKIPPED NOT_RUN: click(findTestObject(“test result 2/Page_Test Procedure 0221/input_File select”))
2021-10-15 13:20:48.749 DEBUG testcase.test result 2 - 36: delay(10)
2021-10-15 13:20:58.781 DEBUG testcase.test result 2 - 37: click(findTestObject(“test result 2/Page_Test Procedure 0221/input_Upload Files btn”))
2021-10-15 13:20:59.209 DEBUG testcase.test result 2 - 38: click(findTestObject(“test result 2/Page_Test Procedure 0221/input_save step”))
2021-10-15 13:21:01.959 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to click on object ‘Object Repository/test result 2/Page_Test Procedure 0221/input_save step’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/test result 2/Page_Test Procedure 0221/input_save step’
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)

Your message is saying that it could not click on the statement:
WebUI.click(findTestObject("test result 2/Page_Test Procedure 0221/input_save step"))

And you cut off the rest of the error message.

yes, the last failed step is for uploading the image. I have question for step 32 to 37 where I try to select the image. web testing shows successful but image is not selected. once the image is selected I can upload it.

2021-10-15 13:34:50.137 DEBUG testcase.test result 2 - 32: click(findTestObject(“test result 2/Page_Test Procedure 0221/span_Upload Files”))
2021-10-15 13:34:50.593 DEBUG testcase.test result 2 - 33: sendKeys(findTestObject(“test result 2/Page_Test Procedure 0221/input_File select”), file)
2021-10-15 13:34:50.594 WARN testcase.test result 2 - SKIPPED NOT_RUN: sendKeys(findTestObject(“test result 2/Page_Test Procedure 0221/input_File select”), file)
2021-10-15 13:34:50.594 DEBUG testcase.test result 2 - 34: uploadFile(findTestObject(“test result 2/Page_Test Procedure 0221/input_File select”), “C:\Users\KParekh\Katalon studio guide\Katalon xpath sc\Add_FRS.png”)
2021-10-15 13:34:51.886 DEBUG testcase.test result 2 - 35: click(findTestObject(“test result 2/Page_Test Procedure 0221/input_File select”))
2021-10-15 13:34:51.887 WARN testcase.test result 2 - SKIPPED NOT_RUN: click(findTestObject(“test result 2/Page_Test Procedure 0221/input_File select”))
2021-10-15 13:34:51.888 DEBUG testcase.test result 2 - 36: delay(10)
2021-10-15 13:35:01.915 DEBUG testcase.test result 2 - 37: click(findTestObject(“test result 2/Page_Test Procedure 0221/input_Upload Files btn”))
2021-10-15 13:35:02.348 DEBUG testcase.test result 2 - 38: click(findTestObject(“test result 2/Page_Test Procedure 0221/input_save step”))
2021-10-15 13:35:04.772 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to click on object ‘Object Repository/test result 2/Page_Test Procedure 0221/input_save step’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/test result 2/Page_Test Procedure 0221/input_save step’
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.ClickKeyword.click(ClickKeyword.groovy:75)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:42)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:620)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$3.call(Unknown Source)
at test result 2.run(test result 2:113)
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:430)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:421)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:400)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:392)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:273)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1634319266875.run(TempTestCase1634319266875.groovy:25)
Caused by: org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element is not clickable at point (1192, 7). Other element would receive the click:


(Session info: chrome=94.0.4606.81)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘CA-0FKNQFK’, ip: ‘192.168.1.104’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_282’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver

Do you have something, like a pop-up, over the element? Maybe you need to click elsewhere for the mystery element to disappear for a timeout and then continue with your script. You may even have multiple elements at the same level and you are not selecting the correct one.

1 Like

yes , it allows to upload when i clicked elsewhere. Thank you so much.