I am very new to Xpath and html. Could anyone please tell me how to use xpath to extract the text ('Nicht verfugbar') shown in the attached pic?
Thanks a lot!
The web page I am talking about here is
https://de.louisvuitton.com/deu-de/produkte/nano-speedy-monogram-010575
You can try with
//span[#class='lv-stock-indicator lv-product-stock-indicator lv-product__stock list-label-m -not-available']/text()
The class of the span is unique, so it can be used for location.
More info:
https://www.guru99.com/xpath-selenium.html
Related
I’m trying get the list of texts from the filter area. What is the XPath I should use? Sorry, I’m not good at XPath.
Thanks in advance for any help.
*edited
You can use classname as xpath to retrieve texts.
(//div[#class="fe"])[1]
I am trying to enter text on search text box on google home page. That I can identify using xpath as //*[#id="q"]. But I wanted to reach to that element using parent child relationship. I am using xpath as below :
`(//form[#id='a'])/div[2]/input[#id='q']`
But when I am running the script, it is giving error that said "no such element". Can someone please tell what I am missing in writing the xpath?
Please upload your HTML code to let us know of the issue better. Meanwhile, Try this .//form[#id='tsf']//input[#name='q'].
Hope it helps.
Snapshots displayed Field as well as Inspect element code. Always faced problem on writing xpath for table element. Xpath copied from Moxilla firbugs is worked sometimes but not always.. can any one tell how to write xpath of above code.... Thanks
You can use this xpath
//table[#class='detailList']/tbody/tr/td[contains(text(),'Business Lease')]
abc
I am not able to locate above element. I tried //*[#id="contact-groups"], but with no success.
Well, XPath is not the best of the methods to find elements. But following will match the links with href = "#".
//a[#href="#"]
Not sure if your scenario is as simple as your question. I did test this with a simple html page.
The locator seems correct. You could try this too:
.//*[#id='contact-groups']
As per HTML code provided you can try below xpaths
//a[#id='contact-groups']
//a[contains(text(),'abc')]
//a[#href='#']
Thanks
I am guessing the link is in an Iframe.
Use the following code to switch to the frame and then click on the link
driver.switchTo().frame("frame-name");
driver.findElement(By.xpath("//a[#id='contact-groups']")).click();
I would like to search for a link on a page by its domain name - possibly using contains()? And then only show the anchor text of that link.
I've been able to get all of the a tag using
//a[contains(text(), 'domain_name')]
but unable to retrieve just the anchor text. Can anybody help?
Just use the text() node:
//a[contains(#href, 'domain_name')]/text()