Please help: identify element id based on text using Selenium RC

48 views
Skip to first unread message

Yuva

unread,
Apr 20, 2017, 4:19:49 AM4/20/17
to Selenium Users
HI all,

I need to  identify element id based on text using Selenium RC with perl.after that i need to click the  element.Because element id will be dynamic


Please find the below html code.So based on google /yahoo text need to find the element id .Please help me here





First time
============
<text id="fcl0otLabel1_546" font-family="&quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif" dominant-baseline="text-before-edge" fill="#FFFFFF" font-size="14px" transform="matrix(1,0,0,1,40,0)">yahoo</text>

<text id="fcl11otLabel1_100" font-family="&quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif" dominant-baseline="text-before-edge" fill="#FFFFFF" font-size="14px" transform="matrix(1,0,0,1,40,0)">google</text>

Second time
=================
<text id="fcl48otLabel1_55" font-family="&quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif" dominant-baseline="text-before-edge" fill="#FFFFFF" font-size="14px" transform="matrix(1,0,0,1,40,0)">yahoo</text>

<text id="fcl1891otLabel1_67100" font-family="&quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif" dominant-baseline="text-before-edge" fill="#FFFFFF" font-size="14px" transform="matrix(1,0,0,1,40,0)">google</text>


Entire Html tag

<g transform="matrix(1,0,0,1,92,1085)" cursor="pointer" id="N8"><g transform="matrix(31.88888888888889,0,0,5.888888888888889,0,0)" pointer-events="none" id="zijpgl7_133_g"><rect fill="rgba(0,0,0,0)" height="9" width="9" id="zijpgl7_133"></rect><rect fill="#6E8598" height="9" width="9" y="0" x="0" id="zijm2_134_m"></rect></g><rect fill="rgba(0,0,0,0)" height="53" width="287"></rect><rect fill="rgba(0,0,0,0)" height="53" width="287" id="zijpgl6_128"></rect><image transform="matrix(1,0,0,1,18.99999855,18.5)" preserveAspectRatio="none" xlink:href="/em/sdkImpl/core/schematic/images/up-statusIcon-16x16.png" height="16" width="16" y="0" x="0" id="fco0m1_132_m"></image><g id="fcpglLabel1_129_g"><rect fill="rgba(0,0,0,0)" height="53" width="247" id="fcpglLabel1_129"></rect><g transform="matrix(1,0,0,1,0,18.625)" id="fcl0pglLabel2_130_g"><rect fill="rgba(0,0,0,0)" height="15.75" width="247" id="fcl0pglLabel2_130"></rect><rect fill="none" height="1" width="40"></rect><text transform="matrix(1,0,0,1,40,0)" font-size="14px" fill="#FFFFFF" dominant-baseline="text-before-edge" font-family="&quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif" id="fcl0otLabel1_131">yahoo</text></g></g><desc>yahoo</desc></g>

Thx in advance

Yuva

unread,
Apr 21, 2017, 2:27:11 AM4/21/17
to Selenium Users
Hi all,

Please help me here

Yuva

unread,
Apr 22, 2017, 6:10:32 AM4/22/17
to Selenium Users
Hi all,

Please help me here

markg

unread,
Apr 22, 2017, 2:37:13 PM4/22/17
to Selenium Users
use xpath similar to .//text[contains(.,'yahoo')] with FindsByXpath()

stevs...@gmail.com

unread,
Apr 24, 2017, 10:26:55 AM4/24/17
to Selenium Users
You can use xpath to find your element e.g.

1. Using contains and '.' to find the text anywhere

xpath=//button[contains(.,'text to find')]

2. Selecting a link with 'Go to application in the title

xpath=//a[contains(@title,'Go to application')]
Reply all
Reply to author
Forward
0 new messages