How to check image cropping (selection) using Selenium?

Using Jcrop, you can select part of the image to crop later on the server: http://deepliquid.com/projects/Jcrop/demos.php I want to check this with selenium. Can I somehow tell the browser to select part of the image using mouseDownAt (), etc.? Can I control the mouse directly?

+3
source share
2 answers

No, currently you cannot directly control the mouse.

This cannot be verified with Selenium. = (

0
source

This can be done using the Actions class.

Actions crop = new Actions(driver);
private By elementBy = By.cssSelector("<css selector for the element>");

//Move to the desired co-ordinates of the image element, In the code below I am staring from bottom left corner of the image
crop.moveToElement(driver.findElement(elementBy),0,0);

//locate the co-ordinates of image you want to move by and perform the click   and hold which mimics the crop action 
crop.clickAndHold().moveByOffset(196,238).release().build().perform();
0
source

All Articles