How to get the selected value of ExtJS combobox through selenium? How to get the selected value of ExtJS combobox through selenium? selenium selenium

How to get the selected value of ExtJS combobox through selenium?


Eexecute JS using selenium(How to use JavaScript with Selenium WebDriver Java). In js you can use "Ext.ComponentQuery.query('combo')[0].value" code to get combo value


To get text in dropDown element which is selected you need to iterate through all divs in x-combo-list-inner, gets it class value and if it contains x-combo-selected then return it's text. Not sure about correctness of js but this should look like (i haven't tested this code):

driver.findElement(webdriver.By.css(".x-combo-list-inner")).then(function(parentElement) {    return parentElement.findElements(".x-combo-list-item").then(function(innerElements) {        return innerElements.forEach(function(elem) {            return elem.getAttribute('class').then(function(classValue) {                if(classValue.indexOf('x-combo-selected') > -1) {                    return elem.getText();                }            });        });    });});