JamesArmes
JamesArmes

Reputation: 1373

Selenium element not found

I am writing a Selenium test in PHP to check the performance of a web application in Firefox. I want to use this as a base-line for comparing different performance enhancements (upgrading JQuery, PHP 5.3, etc.). The web application is very AJAX intense and so far I have only run into one problem.

I have an AJAX call that loads content into an existing div. To test if the call is complete I am using the following line of code:

$selenium->waitForCondition('$(\'div[id="divId"]\').height() > 100', $timeout);

This is working as I expected, but when I attempt to type into any input loaded into the div, selenium throws the error "Element input[@id="inputId"] not found".

I have verified that the id for the input is correct and I have tried with other input elements that are loaded inside the div and none of them work. I have also attempted to add a sleep(30) so that i know for sure the elements are in the DOM and on the screen, but again it made no difference.

I am really stuck at this point and can't move on until I get this issue resolved. Any help is greatly appreciated.

Thanks, James Armes

Upvotes: 3

Views: 4838

Answers (1)

John Feminella
John Feminella

Reputation: 311605

I'd look at a few things:

  1. Make sure that the condition you're checking against isn't true before the items are loaded. Checking height seems suspicious, for example -- wouldn't it be better to test if there are any children present inside the div?

  2. Depending on how you write the selector, Selenium may be thinking that input[@id='inputId'] is the actual identifier for the selector (and not just inputId). Make sure that this isn't the case. Try just using inputId, which should be sufficient since it's an identifier.

  3. Selenium can be finicky. Try different browsers to see if you get different results. If so, it may represent an area that Selenium's not covering well. Although these are generally few and far between, it's possible. But we'd need to see more code before it'd be sure that this is the case.

Upvotes: 4

Related Questions