在http://seleniumexamples.com/blog/examples/select-an-option-from-an-extjs-combobox/介绍了Selenium RC client java library如何实现这个功能,非常巧妙,可以当作一种标准做法。但是列出来的代码有问题,执行中会报错:" Got result: missing ) after argument list on session",原因是参数要用双引号。以下是修改过的代码:
//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");