Selenium WebDriver to select combo-box item?

后端 未结 4 1900
情深已故
情深已故 2020-12-31 05:41

We are using Selenium WebDriver and JBehave to run \"integration\" tests on our web-app. I have a method that will enter a value into a form input.

@When(\         


        
4条回答
  •  再見小時候
    2020-12-31 06:12

    By using ext js combobox typeAhead to make the values visible in UI.

    var theCombo = new Ext.form.ComboBox({  
    ...
    id: combo_id,
    typeAhead: true,
    ...
    });
    
    driver.findElement(By.id("combo_id-inputEl")).clear();
    driver.findElement(By.id("combo_id-inputEl")).sendKeys("The Value you need");
    driver.findElement(By.id("combo_id-inputEl")).sendKeys(Keys.ARROW_DOWN);
    driver.findElement(By.id("combo_id-inputEl")).sendKeys(Keys.ENTER);
    

    If that doesn´t work this is also worth a try

    driver.findElement(By.id("combo_id-inputEl")).sendKeys("The Value you need");
    driver.findElement(By.className("x-boundlist-item")).click();
    

提交回复
热议问题