Handling Canvas in Selenium

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Handling Canvas in Selenium

Harsh Bedi
Need help to handle Canvas in Selenium.

I am working on a website, it have canvas & different buttons present on it.But in DOM id for these buttons are not present its only the Canvas tag.
Please help me how can i get id of an element present on Canvas.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c95954ff-6ace-4a14-836e-d80757215c3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Handling Canvas in Selenium

Joe Ward
You can't. Things drawn on a variable size canvas element are part of the same canvas element, not different elements in their own right.

On 31 May 2018 at 07:49, Harsh Bedi <[hidden email]> wrote:
Need help to handle Canvas in Selenium.

I am working on a website, it have canvas & different buttons present on it.But in DOM id for these buttons are not present its only the Canvas tag.
Please help me how can i get id of an element present on Canvas.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c95954ff-6ace-4a14-836e-d80757215c3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAJPyTs3-8zxemmmM8MtjJTqKVbNCiTvBN6t4q3WmV5swdZ%3DMmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Handling Canvas in Selenium

Harsh Bedi
Thanks for the reply Joe. But how should I write selenium code around this then.
How should I click on some element present on canvas then.

Thanks in advance

On Thu 31 May, 2018, 3:42 PM Joe Ward, <[hidden email]> wrote:
You can't. Things drawn on a variable size canvas element are part of the same canvas element, not different elements in their own right.

On 31 May 2018 at 07:49, Harsh Bedi <[hidden email]> wrote:
Need help to handle Canvas in Selenium.

I am working on a website, it have canvas & different buttons present on it.But in DOM id for these buttons are not present its only the Canvas tag.
Please help me how can i get id of an element present on Canvas.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c95954ff-6ace-4a14-836e-d80757215c3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAJPyTs3-8zxemmmM8MtjJTqKVbNCiTvBN6t4q3WmV5swdZ%3DMmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CACm6CyR_qTECGywmfyGB6tMROQw3dM1-7vDFV9LMtV9wesf9jw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Handling Canvas in Selenium

David
Is this canvas a fixed size regardless of how browser is resized? And are the elements inside at fixed locations? If so, you might be able to use Selenium API or javascript to click at x,y offset from canvas (top left corner I believe). And if that doesn't work, you have option of looking into 3rd party image based tools like Sikuli, etc. to also click at offset from known image (the canvas).

Another option is to research into whether you can manipulate the elements inside the SVG via javascript, e.g. get it's object handle, click it, etc. That could be easier if your organization owns the canvas widget/element.

On Thursday, May 31, 2018 at 3:23:35 AM UTC-7, Harsh Bedi wrote:
Thanks for the reply Joe. But how should I write selenium code around this then.
How should I click on some element present on canvas then.

Thanks in advance

On Thu 31 May, 2018, 3:42 PM Joe Ward, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="yCT36EsmAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ddl...@...> wrote:
You can't. Things drawn on a variable size canvas element are part of the same canvas element, not different elements in their own right.

On 31 May 2018 at 07:49, Harsh Bedi <<a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="yCT36EsmAAAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">harsh...@...> wrote:
Need help to handle Canvas in Selenium.

I am working on a website, it have canvas & different buttons present on it.But in DOM id for these buttons are not present its only the Canvas tag.
Please help me how can i get id of an element present on Canvas.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="yCT36EsmAAAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="yCT36EsmAAAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/c95954ff-6ace-4a14-836e-d80757215c3a%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/c95954ff-6ace-4a14-836e-d80757215c3a%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/c95954ff-6ace-4a14-836e-d80757215c3a%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/c95954ff-6ace-4a14-836e-d80757215c3a%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="yCT36EsmAAAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="yCT36EsmAAAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/CAJPyTs3-8zxemmmM8MtjJTqKVbNCiTvBN6t4q3WmV5swdZ%3DMmg%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/CAJPyTs3-8zxemmmM8MtjJTqKVbNCiTvBN6t4q3WmV5swdZ%3DMmg%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/CAJPyTs3-8zxemmmM8MtjJTqKVbNCiTvBN6t4q3WmV5swdZ%3DMmg%40mail.gmail.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/CAJPyTs3-8zxemmmM8MtjJTqKVbNCiTvBN6t4q3WmV5swdZ%3DMmg%40mail.gmail.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1a64e51e-93fd-4a09-b254-3d4cff8130e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Handling Canvas in Selenium

Joe Ward
David has this exactly right IMO!

On 31 May 2018 at 20:56, David <[hidden email]> wrote:
Is this canvas a fixed size regardless of how browser is resized? And are the elements inside at fixed locations? If so, you might be able to use Selenium API or javascript to click at x,y offset from canvas (top left corner I believe). And if that doesn't work, you have option of looking into 3rd party image based tools like Sikuli, etc. to also click at offset from known image (the canvas).

Another option is to research into whether you can manipulate the elements inside the SVG via javascript, e.g. get it's object handle, click it, etc. That could be easier if your organization owns the canvas widget/element.

On Thursday, May 31, 2018 at 3:23:35 AM UTC-7, Harsh Bedi wrote:
Thanks for the reply Joe. But how should I write selenium code around this then.
How should I click on some element present on canvas then.

Thanks in advance

On Thu 31 May, 2018, 3:42 PM Joe Ward, <[hidden email]> wrote:
You can't. Things drawn on a variable size canvas element are part of the same canvas element, not different elements in their own right.

On 31 May 2018 at 07:49, Harsh Bedi <[hidden email]> wrote:
Need help to handle Canvas in Selenium.

I am working on a website, it have canvas & different buttons present on it.But in DOM id for these buttons are not present its only the Canvas tag.
Please help me how can i get id of an element present on Canvas.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c95954ff-6ace-4a14-836e-d80757215c3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAJPyTs3-8zxemmmM8MtjJTqKVbNCiTvBN6t4q3WmV5swdZ%3DMmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1a64e51e-93fd-4a09-b254-3d4cff8130e8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAJPyTs0Euz1mq9bZ3CgH2kMjWUgLGzVqAorxdsr4%2BabD6Ct5wQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Handling Canvas in Selenium

Harsh Bedi
Appreciate the help David  & Joe. I think i can make progress now. :)

On Fri, Jun 1, 2018 at 11:54 AM, Joe Ward <[hidden email]> wrote:
David has this exactly right IMO!

On 31 May 2018 at 20:56, David <[hidden email]> wrote:
Is this canvas a fixed size regardless of how browser is resized? And are the elements inside at fixed locations? If so, you might be able to use Selenium API or javascript to click at x,y offset from canvas (top left corner I believe). And if that doesn't work, you have option of looking into 3rd party image based tools like Sikuli, etc. to also click at offset from known image (the canvas).

Another option is to research into whether you can manipulate the elements inside the SVG via javascript, e.g. get it's object handle, click it, etc. That could be easier if your organization owns the canvas widget/element.

On Thursday, May 31, 2018 at 3:23:35 AM UTC-7, Harsh Bedi wrote:
Thanks for the reply Joe. But how should I write selenium code around this then.
How should I click on some element present on canvas then.

Thanks in advance

On Thu 31 May, 2018, 3:42 PM Joe Ward, <[hidden email]> wrote:
You can't. Things drawn on a variable size canvas element are part of the same canvas element, not different elements in their own right.

On 31 May 2018 at 07:49, Harsh Bedi <[hidden email]> wrote:
Need help to handle Canvas in Selenium.

I am working on a website, it have canvas & different buttons present on it.But in DOM id for these buttons are not present its only the Canvas tag.
Please help me how can i get id of an element present on Canvas.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c95954ff-6ace-4a14-836e-d80757215c3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAJPyTs3-8zxemmmM8MtjJTqKVbNCiTvBN6t4q3WmV5swdZ%3DMmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1a64e51e-93fd-4a09-b254-3d4cff8130e8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAJPyTs0Euz1mq9bZ3CgH2kMjWUgLGzVqAorxdsr4%2BabD6Ct5wQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Thanks & Regards
Harsh Bedi

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CACm6CySoA_C4v9O%3D-LaWyMoU%3DyUCQP8JcP4uAuAbRHKPzskRUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.