I need to find the
xpath for the line in the image with highlighted text. The highlighted text/number is dynamic. Once I find the
xpath, I can save it in a variable using
Kindly help me. I am kind a stuck on it for a while
Your text is dynamic, but it always contains
.xlsx. So you can find the element with partial text matching.
Or more specifically:
By.xpath("//td[@id = 'noOfSites_row1 text-center' and contains(text(), 'xlsx')]")
Inspect the webpage and press
ctrl + F. Then in the search bar paste the above command and search how many web elements gets matches. If multiple elements matches then pass the number where it is occurred.
Your xpath would be
Since according to your question you need the very first line and the second column of the table. You there are more specific criteria you can describe them in the comments to my answer.
The simple way is
//table[@id='fileUploadTable']/tbody/tr/td but you can use more smarter way something like this:
//table[@id='fileUploadTable']/tbody/tr[td = "*.xlsx"] Please check it. It should work. You can find additional info by the link Xpath
This should definitely works.
WebDriver driver=null; driver.findElement(By.xpath("//table[@id = 'fileUploadTable']/tbody/tr/td/a")).click();
.//*[contains(@id,'text-center') and contains(text(), 'xlsx')]
Give me HTML I will give you more if required. Don't use any tool which gives you a ready made xpath. Try to write on your own so you better understand how xpath works.