How do I set an option as selected using Selenium WebDriver (selenium 2.0) client in ruby

前端 未结 10 1346
难免孤独
难免孤独 2020-12-14 00:46

I am trying to get familiar with the new ruby selenium-webdriver as it appears more intuitive mostly than the previous version of selenium and the ruby driver that went with

10条回答
  •  心在旅途
    2020-12-14 01:11

    For the latest version of Webdriver (RC3) you should use "click()" instead of setSelected(). Also option.getText().equals("Name you want") should be used instead of option.getText()=="Name you want" in JAVA:

     
    WebElement select = driver.findElement(By.name("select"));
    List options = select.findElements(By.tagName("option"));
    for(WebElement option : options){
        if(option.getText().equals("Name you want"){
            option.click();
            break;
        }
    }
    

提交回复
热议问题