开发者

How to test image cropping (selecting) with Selenium?

开发者 https://www.devze.com 2023-02-16 02:19 出处:网络
With Jcrop one can select parts of an image to crop it later on serverside: http://deepliquid.co开发者_如何学Cm/projects/Jcrop/demos.php I want to test this with selenium. Can i somehow tell the brows

With Jcrop one can select parts of an image to crop it later on serverside: http://deepliquid.co开发者_如何学Cm/projects/Jcrop/demos.php I want to test this with selenium. Can i somehow tell the browser to select a part of the image with mouseDownAt() etc? Can i even control the mouse directly?


No, currently you can't control the mouse directly.

This might not be testable with Selenium. =(


This could be done by using 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

精彩评论

暂无评论...
验证码 换一张
取 消