While automating my web app, i ended up in this peculiar situation.
I was using firepath to assist me in creating Xpath. Well, while scripting, it evaluated my xpaths correctly. But during execution, it was not able to locate the elements!
Rootcause: Application window was divided into 3 parts:
- Main window
- Frame1
- Frame2
While using firebug, I seldom noticed one small drop-down on left top corner of the Firebug window:

While inspecting element, the value in this drop-down automatically was switching to relevant frame. So i didnt had any clue that my web-app was having 2 frames in it.

So when the script navigated from previous page to the next one (where the page gets divided into 3 sections as mentioned above), script was failing to locate elements since i hadnt asked the driver to switch to 2nd frame.
So all i had to do was, write this line of code to overcome the issue
driver.switchTo().frame(1);
And it started working 🙂