0
votes

When testing an ext-js application with Selenium (WebDriver), I have a button that brings up a dialog. The test then fills out some form fields, clicks buttons, etc. The problem is that selenium starts performing these actions before the dialog is fully done building.

I know that I can tell selenium to wait for a specific element to appear, but if I want to generalize the case to "wait for the dialog to finish loading", is there a way to do that?

1
What is the difference between dialog and some other element? Why not to check presence of some dialog's DOM element?udalmik
I'd like to know if the whole DOM is finished loading, rather than just a specific elementJeff Storey
You could write more complex condition (check some variable, popup state, etc.) and wrap it with WebDriverWait seleniumhq.org/docs/04_webdriver_advanced.htmludalmik
I think the issue is more that extjs uses dynamic ids when generating some components, making it difficult to find them and know exactly what to wait forJeff Storey

1 Answers

3
votes

The short answer is, "No, theres no simple way to do that." to understand why this is so, consider this: How do you define "the whole DOM is loaded?" Is it when the last closing </html> tag is downloaded? When it's parsed and added to the DOM? Is it when the document readyState property is "interactive," "contentReady," or some other value? What about DOM elements added via JavaScript? What if that JavaScript is fired via setTimeout()? What about processing XmlHttpRequests? There is no one-size-fits-all answer to that question that is correct 100% of the time for all use cases.

Waiting for an element is the right approach. Identifying the right element can be challenging when using extJs, because of the generated IDs. I've often found it more effective to use class attributes with that particular JavaScript framework.