Upload / Attach File

how to upload file ,
I have option : when I click then mentioned screen will open, how to select image ?

There is the “upload” statement that you can try.

Example:
WebUI.uploadFile(findTestObject(‘input_browse’), ‘D:\test-photo.png’)

Additionally, you might be able to use the Robot to assist you.

import java.awt.Robot
import java.awt.Toolkit
import java.awt.datatransfer.StringSelection
import java.awt.event.KeyEvent


StringSelection ss = new StringSelection('pathway to file.txt');
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);

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);

WebUI.waitForPageLoad(10)

Hi @noor.ahmed, This could help too: How-to use ‘sendKeys’ or 'File Upload' to upload files

1 Like