How to upload image using sikuli

Though webdriver handles the file uploading smartly but there are some time when you need to work with external tools such as AutoIT, again AutoIT doesn't go good with linux system hence we may use sikuli to upload the image.
Click on link which will populate the file upload dialog, and take printscreen for Fileupload area and open button and save them in some location.



Pattern fileLoad = new Pattern("{yourPath}/FileLoadInput.png");

Pattern openButton = new Pattern("{yourPath}/openButton.png");

Screen src = new Screen();
src.setAutoWaitTimeout(30);

// Clear the input field if any is selected by default.
src.type("a", Key.CTRL);
src.type(Key.BACKSPACE);

//Type in input filed name of the image and click on open button
src.type(fileLoad, sFileName);
src.click(openButton);

Comments

Popular posts from this blog

Comparing sum of string's digit by splitting string in 2 halfs

Parsing xml node tags using documentbuilderfactory

How to generate string with given range.