Manikandan
Manikandan

Reputation: 417

How to automate the action on a canvas object, when the canvas element has no name or ID in Selenium?

I am having a canvas object, which is used for digital signature...I want to try, to automate that action using selenium...

I found out that,

selenium.clickAt("canvas_element_name","co-ordinates"); 

can do the good...`(coordinates like, "30, 40")..But the case is there is no name for the canvas element given...By.xpath is not working in conjunction with selenium.clickAt...

other method, which I found out was,

driver.findElement(By.xpath("html/body/form/div/canvas")).click();
driver.findElement(By.xpath("html/body/form/div/canvas")).click();

But, both didn't work...I even tried try, catch for the second method...

Pls. find the HTML code in the thread, for getting the idea on the element looks like in the page...

https://sqa.stackexchange.com/questions/3253/how-to-automate-the-action-on-a-canvas-object-when-the-canvas-element-has-no-na

Any suggestions and workarounds for this one?

Upvotes: 1

Views: 9253

Answers (1)

Petr Janeček
Petr Janeček

Reputation: 38424

I can't see any <canvas> element in the source you posted in the other question.

If the element is hidden in a <frame> or <iframe> element, you must driver.switchTo() (for WebDriver) or selenium.selectFrame() (for Selenium RC) the frame first.

If it's created dynamically (via JS), you must wait for it to become usable.

Upvotes: 1

Related Questions