Hi there.
I’m trying to upload file using customkeyword.
I succeeded in Chrome normal mode but I failed in headless mode.
There was no fail and error log.
I checked the results by comparing the two screenshots.
customkeyword
public class customFileupload {
@Keyword
def uploadFile(TestObject to, String inputfilePath) {
WebUI.click(to)
String userDir = System.getProperty(“user.dir”)
String filePath = userDir + "\" + inputfilePath
StringSelection ss = new StringSelection(filePath);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
WebUI.delay(2)
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
robot.delay(1000);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.delay(1000);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}
}
Testcase
CustomKeywords.‘userdefinepkg.customFileupload.uploadFile’(findTestObject(‘Page_Company_Application_resistResume_Basicinfo/button_picture’),
'123.jpg')
WebUI.takeScreenshot(‘D:\\test2.png’)
Please help.
Thank you.