2011-11-14 25 views
0

我们有一个基于RichFaces 3.3.3的应用程序。我们用Selenium IDE创建了自动化测试,运行良好。由于RichFaces的组合框并不是真正的HTML组合框,但与一群的JavaScript的输入领域,硒,我们需要选择与下面的技巧值:如何使用Selenium Webdriver测试RichFaces组合框?

type  field_id "field value" 
typeKeys field_id "field value" 
fireEvent field_id "blur" 

为了测试整合到我们的持续集成系统,我们已将测试转换为使用WebDriver(Selenium 2.5.0)作为后端的jUnit测试。不幸的是,组合框技巧停止工作。

所有类型和typeKeys命令被翻译,如下所示:

// ERROR: Caught exception [ERROR: Unsupported command [fireEvent]] 
driver.findElement(By.id("patientCreateDataForm:patientBirthDateInputDate")).clear(); 
driver.findElement(By.id("patientCreateDataForm:patientBirthDateInputDate")).sendKeys("16.06.1910"); 

没有人有任何工作溶液,以测试RichFaces的组合框元件?

在此先感谢!

回答

1

的解决方案如下:

  1. 点击在RichFaces的组合框
  2. 选择项(男或女)和复制路径以帮助FirePath
  3. 其后使用操作方法在JUnit测试。在以下示例中,按钮参数是一个组合框按钮的ID,被选择的元件参数的项目的xpath:

    private void comboboxSolution(String element, String button) { 
        WebElement btn = driver.findElement(By.id(button)); 
        btn.click(); 
        WebElement myElement = driver.findElement(By.xpath(element)); 
        Actions builder = new Actions(driver); 
        builder.moveToElement(myElement).click().perform(); 
    
    } 
    
0

尝试这样:

typeKeys field_id "field value" 
waitForVisible (look with firebug at the id of the div that becomes visible after typing) 
click (look with firebug at the id of the entry you want to select) 
waitForNotVisible the_id_of_the previous_div 

我有这样的解决方案,丰富的工作:suggestionbox组成部分,它应该是一个组合框容易适应。

+0

这似乎是一个硒溶液。我们对硒没有问题,但是如果我们将测试用例导出到WebDriver jUnit脚本,它们不会选择组合框中的元素。我用生成的webdriver代码更新了这个问题。 – pentike

相关问题