Sajitha Pathirana
Nov 2 · 1 min read

Hi Purvi Dholakia,

Thank you for the feedback.
I copied your html snippet from stackoverflow. Please check the below xpath.

//div[contains(@class,’l1 r1')]//*[name()=’svg’]//*[name()=’g’]//*[name()=’rect’]

Few Points:

  • Try to write relative xpaths rather than absolute xpaths
  • Most of the time ids generated for SVG elements are dynamic, since they are generated/rendered on the fly when you expand parent elements.
    Sajitha Pathirana

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade