selenium webdriver - How to find xpath from javascript href -


the scenario need check default elements present on web page. trying check headers available on web table. able find headers except 1 name ip address / host name

<div id="ctl00_contentplaceholder1_radgrid1_gridheader" class="rgheaderdiv" style="overflow: hidden;"> <table id="ctl00_contentplaceholder1_radgrid1_ctl00_header" class="rgmastertable rgclipcells rgclipcells" style="border-color:#6788be;border-width:1px;border-style:solid;width:100%;table-layout:fixed;overflow:hidden;empty-cells:show;"> <colgroup> <thead> <tr> <th class="rgheader rgsorted" style="font-weight:bold;font-style:normal;text-decoration:none;text-align:left;" scope="col"> <a href="javascript:__dopostback('ctl00$contentplaceholder1$radgrid1$ctl00$ctl02$ctl01$ctl05','')" title="click here sort" onclick="telerik.web.ui.grid.sort($find('ctl00_contentplaceholder1_radgrid1_ctl00'), 'hostip'); return false;">ip address / host name</a> <input class="rgsortasc" type="button" title="sorted asc" onclick="javascript:__dopostback('ctl00$contentplaceholder1$radgrid1$ctl00$ctl02$ctl01$ctl06','')" value=" " name="ctl00$contentplaceholder1$radgrid1$ctl00$ctl02$ctl01$ctl06"> </th> </tr> </thead> <tbody style="display:none;"> </table> </div> 

i tried finding using below codes failed so. driver.findelement(by.xpath("//div[@id='ctl00_contentplaceholder1_radgrid1_gridheader']//a[contains(@href,'ip address / host name')]"));

driver.findelement(by.xpath("//a[contains(@href,'ip address')]"));

driver.findelement(by.linktext(ip address / host name));

i tried changing div id , value ti table id , corresponding value script fail saying not able find element xpath...

my script says failed find element id... or xpath... please help.

if you're having trouble accessing element programmatically, advice use selenium ide select element, export test case going file > export test case as... > java / junit 4 / webdriver.

i tried myself , resulting code uses:

driver.findelement(by.linktext("ip address / host name"))

it seems work fine in selenium ide. haven't tested resulting java code. - syntax, appears you're using java.

you you've tried using by.linktext(), maybe there's bigger problem? (i notice don't have quotes around by.linktext() example, assume typo.)


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -