Click on SVG component which are having dynamic id's | Selenium Forum
M
Posted on 05/06/2016
Hi Team,

In my project i saw UI generator tool which generates dynamic id's for SVG components.

So id's are like this .//*[@id='_dvtActiveElement338135989']

So i want to generate my own xpath in order to handle it but unfortunately its not working. Can you say how to handle such sceanrios, where UI components are like svg donut chart and all ?

Below is dom hierarchy :

<div id="dashboard-device-status-donut-chart" class="oj-dvtbase oj-chart oj-component-initnode" data-bind="style: donutStyle, ojComponent: { component: 'ojChart', type: 'pie', emptyText: emptyTextPie, styleDefaults: styleDefaults, legend: legend, series: deviceStatus, tooltip: tooltipDeviceStatus, drilling: 'on', drill: drillDeviceStatus, hoverBehavior: 'dim', pieCenterLabel: pieCenterLabel, optionChange: optionChange }" style="width: 100%; height: 360px; float: left; z-index: 40;" tabindex="0" role="application" aria-label="Data Visualization: Chart" aria-activedescendant="_dvtActiveElement338135989">
<div class="oj-helper-detect-contraction">
<div class="oj-helper-detect-expansion">
<div style="visibility:hidden;"/>
<svg width="100%" height="100%">
<defs/>
<g cursor="default" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="12px">
<g cursor="inherit">
<g>
<rect width="400" height="360" fill="rgba(0,0,0,0)"/>
<g>
<g>
<path id="_dvtActiveElement338135989" d="M200.75,48.332136039199014L200.75,26.001826309530543A154,154,0,0,1,206.52331186071902,26.13822306249091L205.46877584026603,48.443618965825465A131.67,131.67,0,0,0,200.75,48.332136039199014Z" fill="#309FDB" cursor="pointer" role="img" aria-label="Series: Registered; Value: 1.000; Percentage: 1.000. Drillable"/>
<path d="M206.2180399418538,48.47690362798818L207.2725613355015,26.17181710875809A154,154,0,1,1,200,26L200,48.33000000000001A131.67,131.67,0,1,0,206.2180399418538,48.47690362798818Z" fill="#f5ce45" cursor="pointer" role="img" aria-label="Series: Offline; Value: 132.0; Percentage: 132.0. Drillable" opacity="0.35"/>
</g>
</g>
</g>
</g>
</g>
</svg>
</div>

M
Replied on 07/06/2016

watch module 12

Handling Dynamic objects/ids on the page