0

I'm trying to grab the value of a TD with no ID but the TR has a class. The other issue is there are multiple tables on the same page, also with no ID. Please see below:

enter image description here

I need to get the value for Machine ID and Total Memory that is underlined in the screenshot above

Here's what I tried:

 browser.switch_to.default_content()
 frames = browser.find_elements_by_tag_name('frame')
 browser.switch_to.frame(frames[1])

 value1 = browser.find_element_by_xpath(("//tr[@class='staticProp']/td[1]")).get_attribute("value")
 value2 = browser.find_element_by_xpath(("//tr[@class='staticProp']/td[2]")).get_attribute("value")
 value3 = browser.find_element_by_xpath(("//tr[@class='staticProp']/td[3]")).get_attribute("value")
 value4 =      browser.find_element_by_xpath(("//tr[@class='staticProp']/td[4]")).get_attribute("value")
 value5 = browser.find_element_by_xpath(("//tr[@class='staticProp']/td[5]")).get_attribute("value")



 print(value1)
 print(value2)
 print(value3)
 print(value4)
 print(value5)

But I get none as the results.

Any help is greatly appreciated.

UPDATE

Here's an additional screenshot. Is the : the problem?

enter image description here

Thanks,

1 Answers1

1

Make sure you are in the correct frame and then you can try with the below xpaths.

Machine ID:

//td[.='Machine ID']/parent::tr/td[last()]

Total Memory:

//td[.='Total Memory']/parent::tr/td[last()]
supputuri
  • 13,644
  • 2
  • 21
  • 39
  • Unfortunately still no results. I added an additional screenshot. – Kyocera Alerts Mar 23 '20 at 01:54
  • First try those xpaths in chrome devtools and see if the xpaths working. Then check if you are pointing to right frame. – supputuri Mar 23 '20 at 02:40
  • Refer to [this](https://stackoverflow.com/questions/55870609/is-there-a-way-to-learn-xpath-without-using-firebug-or-xpath-as-firefox-is-not-s/55870909#55870909) post, this will give detailed information how to check xpath/css in chrome devtools. – supputuri Mar 23 '20 at 02:49