0

I'm having some trouble finding an element in a table. The Site is finance.yahoo.com/q/ks?s=GOOG

I'm trying to find that element named "Market Cap (Intraday)" It does have an ID, but I need the other elements in the table as well and they do not. I've traced the xPath I think to this

//table[@id='yfncsumtab']/tbody/tr[2]/td[1]/table[2]/tbody/tr/td/table/tbody/td[1]/td[2]/span

However, it's not spitting out the amount. I'm getting the no_such_element exception (It's not finding it)

Is my xPath correct? Or is there a more streamlined way to find the element?

I can't technically go by class names because they can change with the Stock

jDave1984
  • 838
  • 4
  • 12
  • 37

2 Answers2

0

You got a typo. The correct xpath is:

//table[@id='yfncsumtab']/tbody/tr[2]/td[1]/table[2]/tbody/tr/td/table/tbody/tr[1]/td[2]/span

Your last part had a td that should have been a tr.

An easy way to debug this is using Chrome developer tools, see Is there a way to get the xpath in google chrome?

Community
  • 1
  • 1
Wouter
  • 3,866
  • 2
  • 29
  • 49
0

Instead of writing such a lengthy xpath, you can write simple xpath as following:

//td[text()='Market Cap (intraday)']

which looks for td for which text is Market Cap (intraday). Similarly, you can do for other cells from the table.

Alpha
  • 12,340
  • 22
  • 77
  • 141