Reputation: 197
I have a canvas element (Width: 720, Height : 174). This canvas has 16 parts. I tried
Actions.moveToElement(we,(720/16)*3,1).click().perform();
I want it to click in part 3 of the canvas, but it always clicks in the first part. Please help!
Upvotes: 4
Views: 10165
Reputation: 1
Include the Sikuli library in your project.
Take a screenshot of that area where you want to click and save it in your system with name, perhaps "openButton"
for the following example: (Better if small in area size)
Use the Pattern and Screen classes:
Screen obj = new Screen();
Pattern openButton = new Pattern(filepath + "OpenButton.PNG");
s.click(openButton);
See "How to use Sikuli with Selenium" for more information.
Upvotes: 0
Reputation: 11
For getting co-ordinates of the elements inside canvas tag use any online ruler
Actions clickAt = new Actions(d);
clickAt.moveToElement(d.findElement(By.xpath("your canvas id here")), 60, 30).click();
clickAt.moveToElement(d.findElement(By.xpath("your canvas id here")), 90, 30).click();
clickAt.build().perform();
Upvotes: 1
Reputation: 630
Try
Actions.moveToElement(we,0,0).moveByOffset((720/16)*3,1).click().build().perform();
Upvotes: 3