Automating an ExtJS web application can be difficult due to the dynamic nature of the page. For example, the majority of unique ID attributes in the HTML will be different between builds, which causes problems locating elements reliably. Another issue is selected items from a ComboBox, which is not a normal HTML <select> element, but an <input> that is populated from data in a completely separate section of the DOM.
Below is a solution for locating the ComboBox elements and the Selenium commands needed to select values in them. This example is taken from code written for the Selenium RC Java client library.
1 2 3 4 5 6 7 8 9 10 11 | //click the down arrow image on the right of the ComboBox and assumes that there is a label before the component selenium.click("//label[text()='My Combo List']/following-sibling::div/descendant::img[contains(@class, 'x-form-arrow-trigger')]"); //wait for a drop down list of options to be visible selenium.waitForCondition("var value = selenium.isElementPresent('//div[contains(@class, 'x-combo-list') and contains(@style, 'visibility: visible')]'); value == true", "60000"); //click the required drop down item based on the text of the target item selenium.click("//div[contains(@class, 'x-combo-list')]/descendant::div[contains(@class, 'x-combo-list-item')][text()='My Value']"); //wait for the drop down list of options to be no longer visible selenium.waitForCondition("var value = selenium.isElementPresent('//div[contains(@class, 'x-combo-list') and contains(@style, 'visibility: visible')]'); value == false", "60000"); |









Twitter Updates
Hi, just want to thank you for this howto. I struggled with combobox for a while and even tried to leverage Ext API to test it but your solution is the right one. I just had to replace outer apostrophes in waitForCondition expression with escaped quote marks, without this change I got JS syntax error.
Cool. Glad I could help!
is anyone tried export test case to JUNIT and executed? actually i am trying it with junit, the select is not happening. Any suggestions?
Thank you very much for this example! Works just fine for me