Reputation: 877
This is the code and I need to get the "DDetail" details.
<div style="float:left;padding-left: 7%">
<h2 class="lotnumber style19Bold222" style="float:left"> LOT DETAILS </h2>
<br>
<p class="details style14SemiBold222 styleCapitalize" style="line-height:22px;">
<b class="boldDetails">Materials:</b>
</p>
<p class="style14Reg555"> MDetail </p>
<p class="details style14SemiBold222 styleCapitalize" style="line-height:22px;">
<b class="boldDetails">Measurements:</b>
</p>
<p class="style14Reg555"> MeDetail </p>
<p class="details style14SemiBold222 styleCapitalize" style="line-height:22px;">
<b class="boldDetails">Size Notes:</b>
</p>
<p class="style14Reg555"> total height </p>
<p class="details style14SemiBold222 styleCapitalize" style="line-height:22px;">
<b class="boldDetails">Description:</b>
</p>
<p class="style14Reg555"> stepped square reverse </p>
<p class="details style14SemiBold222 styleCapitalize" style="line-height:22px;">
<b class="boldDetails">Markings:</b>
</p>
<p class="style14Reg555"> MarDetail </p>
<p class="details style14SemiBold222 styleCapitalize" style="line-height:22px;">
<b class="boldDetails">Condition:</b>
</p>
<p class="style14Reg555"> CDetail </p>
</div>
I tried using XPath but it's not working properly because <p>
is not consistent.
I am using JAVA to get this details.
Upvotes: 0
Views: 1044
Reputation: 1
You can use XPath to get the "DDetail" details , java:
driver.findElement(By.xpath("html/body/div[1]/p[8]"))
Upvotes: 0
Reputation: 25596
If you want to get the tag <p class="style14Reg555"> DDetail </p>
you can use the XPath //p[text()=' DDetail ']
.
You didn't specify a language, so here's some Java below.
driver.findElement(By.xpath("//p[text()=' DDetail ']"));
Upvotes: 1
Reputation: 23805
If you want DDetail
on the the basis of Description
try below xPath
:-
Using following
axis :
(//*[contains(text(), 'Description')]/following::p)[1]
Using preceding
axis :
(//p[preceding::b[contains(text(), 'Description')]])[1]
Note :- If you want other details Just change the bold text like if you want MDetail
just change on one of the aboive xpath
text Description
to Materials
Or If you want only on the basis of class name style14Reg555
, try using index in xpath
as below :-
(//p[@class = 'style14Reg555'])[4]
Upvotes: 1