2

I'm trying to scrape this page: http://www.ebay.com/itm/311419628966 using the following XPath:

• .//*[@id='ds_div']
• .//*[@id='pdets']
• .//*[@id='centercolumn']/

But they all throw NoSuchElementException.

This is odd because when I inspect the page with Firebug I'm able to locate the element easily.

Jim Kim
  • 33
  • 1
  • 4

1 Answers1

2

The elements with those id values are inside a frame. You need to switch into its context:

driver.switchTo().frame("desc_ifr");
sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Thanks. Your a genius! May I ask where in the HTML code did you find its an iframe? I suspected it may be an iFrame but did not find the term iFrame anywhere let alone the term "desc_ifr". Where did you find it? – Jim Kim Sep 01 '15 at 03:37
  • @JimKim yeah, there is an `iframe` element with `id="desc_ifr"`. I usually just look up the parents of the desired node and, once I see an `iframe` or `frame` there, I know that I have to change the context of the search and switch to the `iframe`/`frame`. Glad to help and don't forget to accept the answer so we can "resolve" the topic. Thanks! – alecxe Sep 01 '15 at 03:42
  • Accepted. Thanks for explanation. – Jim Kim Sep 01 '15 at 03:46