1

I am not able to find out xpath of Element "Test Drive Request" in Below Html Page. I tried by many xpath but these are getting detect only once while creating in firepath after page refresh if i am again checking then below xpaths are unable to detect element

Below is HTML code

<body scroll="no">
<span id="crmEventManager"/>
<div id="dummyDiv" class="ms-crm-IE7-Height-Fix-Dummy-Container">
<div id="FormCell" style="width: 100%;height: 100%; position: absolute; top: 0px; bottom: 0px;">
<div class="ms-crm-Form-Common-Dummy ms-crm-Form-Container">
<div id="mainContainer" class="ms-crm-Form-Main-Container" style="left: 185px">
<div class="ms-crm-Form-Nav-Container" style="width: 185px">
<div id="crmNavBar" class="ms-crm-FormLeftNav-StandardLayout" style="height: 625px;">
<div id="crmNavBar_paneTD" style="height:100%;">
<div class="ms-crm-FormLeftNav-TabLinksRow">
<div class="ms-crm-Form-LeftBar-Header">
<div class="ms-crm-FormLeftNav-RelatedRow ms-crm-Form-LeftBar">
<ul id="crmFormNavSubareas" class="ms-crm-Nav-LeftBar" style="height: 347px;">
<li class="ms-crm-Nav-Group">
<a id="_NA_Info" class="ms-crm-Nav-Group-Heading" title="Click here for more areas" tabindex="0" target="_self" href="javascript:onclick();" onclick="return false;">
<ul class="ms-crm-Nav-Group-Subareas" style="display:inline;">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<li class="ms-crm-Nav-Subarea">
<a id="nav_fmc_incident_fmc_testdriverequest" class="ms-crm-Nav-Subarea-Link ms-crm-Nav-Subarea-Hovered" onclick="if(typeof(Mscrm)!='undefined'&&typeof(Mscrm.Details)!='undefined'){Mscrm.Details.loadArea(this, 'area_fmc_incident_fmc_testdriverequest');};" title="View Test Drive Requests" tabindex="0" target="_self" href="#">
<img id="" class="ms-crm-Nav-Subarea-Icon" align="absmiddle" alt="" src="/%7B635852537720004376%7D/WebResources/fmc_/Images/HP.FMC.MSS360.CRM.Image.TestDriveRequest16X16"/>
<nobr class="ms-crm-Nav-Subarea-Title" title="View Test Drive Requests">
<div class="ms-crm-Nav-Subarea-Title">Test Drive Requests</div>
</nobr>

I have written below Xpath but these are not working

[![@FindBy(xpath="//div\[contains(text(), 'Test Drive Requests')\]")

@FindBy(xpath=".//*\[@id='crmFormNavSubareas'\]/li\[1\]/ul/li\[13\]/a\]")

@findBy(xpath="//div\[text='Test Drive Requests'\]")
@findBy(xpath = "//nobr\[@title='View Test Drive Requests'\]")][1]][1]

please find attached image for more infoenter image description here

Rahil Kumar
  • 426
  • 8
  • 23

3 Answers3

0

The desired element(s) are inside the iframe, switch to it before looking for the elements:

driver.switchTo().frame("contentIFrame");
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
0

Seems like your element is inside an iframe you may want to switch to iframe first:

driver.switchTo.frame("contentIframe"); //whatever is the name or id of iframe
driver.findElement(By.xpath("//div[contains(text(), 'Test Drive Requests')]"));
Paras
  • 3,197
  • 2
  • 20
  • 30
0

Use this xpath:

.//*[@class='ms-crm-Nav-Subarea-Title' and contains(text(),'Test Drive Requests')]

So it would be:

@findBy(xpath=".//*[@class='ms-crm-Nav-Subarea-Title' and contains(text(),'Test Drive Requests')]")
ManishChristian
  • 3,759
  • 3
  • 22
  • 50