How can you get the text value of this span using the Selenium Web driver?
& lt; Div item type = "http://schema.org/LocalBusiness" style = "float: left;" & Gt; & Lt; Span itemprop = "name" style = "color: # c71d22; font-size: 14px;" & Gt; & Lt; B & gt; Slave Fiscal & lt; / B & gt; & Lt; / Span & gt; & Lt; Br>
I tried with this code but it does not work. Any help please
string kk = driver.findElement (By.xpath ("//*div[@itemtype='http://schema.org/LocalBusiness']/div/span [@ itemprop = 'Name'] ")) gettext () .;
I think the problem is with your XPath:
You are trying to match a node * div
, which has a item per attribute, followed by the div
node Is trying.
Try: // div [@ itemtype = 'http: //schema.org/LocalBusiness'] / span [@ itemprop = 'name']
Which matches div
at any level with the correct item type , then correct your direct child with itemprop span
.
Comments
Post a Comment