Anyone pls…
This part of script
WebUI.click(findTestObject(‘products-add-upload/Page_pr/button_Add image_to_product’))
WebUI.delay(4, FailureHandling.STOP_ON_FAILURE)
WebUI.focus(findTestObject(‘products-add-upload/Page_pr/Upload-image-product-modal’))
CustomKeywords.‘upload.Uploader.uploadFile’(findTestObject(‘products-add-upload/Page_pr/form_Drop files here to upload_product_image’),
'C:\\\Users\\\spiblin\\\Downloads\\\3005471.jpg')
WebUI.delay(5, FailureHandling.STOP_ON_FAILURE)
WebUI.click(findTestObject(‘products-add-upload/Page_pr/button_Save_product_image_after upload’))
And this is a custom keyword
package upload
import java.awt.Robot
public class Uploader {
@Keyword
def uploadFile(TestObject to, String filePath) {
WebUI.click(to)
StringSelection ss = new StringSelection(filePath);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
Robot robot = new Robot();
sleep(3000)
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);
}
}
It fails when Save button doesn’t found
I think it’s because upload is not successful and save window doesn’t appear