Package org.openqa.selenium.support.ui

Examples of org.openqa.selenium.support.ui.Select


    new Select(selectField).selectByVisibleText(optionText);
  }

  protected void selectOptionByValue(WebElement selectField, String optionValue) {
    $(selectField).should(exist).find(byValue(optionValue)).shouldBe(visible);
    new Select(selectField).selectByValue(optionValue);
  }
View Full Code Here


    WebElement option = getSelectedOption(selectElement);
    return option == null ? null : option.getText();
  }

  protected SelenideElement getSelectedOption(WebElement selectElement) {
    return wrap(new Select(selectElement).getFirstSelectedOption());
  }
View Full Code Here

        values.add(new InputValue("1", true));
      } else {
        values.add(new InputValue("0", false));
      }
    } else if (inputString.equals("select")) {
      Select select = new Select(webElement);
      if (!select.getOptions().isEmpty()) {
        WebElement option =
                new RandomInputValueGenerator().getRandomItem(select.getOptions());
        values.add(new InputValue(option.getText(), true));
      }

    }
  }
View Full Code Here

    // Exercise test
    driver.get("http://localhost:" + getServerPort()
        + "/kmf-content-api-test/" + HTMLTEST);
    if (handler != null) {
      Select handlerSelect = new Select(driver.findElement(By
          .id("handler")));
      handlerSelect.selectByValue(handler);
    }
    if (video != null) {
      Select videoSelect = new Select(driver.findElement(By.id("url")));
      videoSelect.selectByValue(video);
    }
    driver.findElement(By.id("play")).click();

    // Specific case: send commands
    if (expectedHandlerFlow != null
View Full Code Here

    // Exercise test
    driver.get("http://localhost:" + getServerPort()
        + "/kmf-content-api-test/" + clientPage);

    if (handler != null) {
      Select handlerSelect = new Select(driver.findElement(By
          .id("handler")));
      handlerSelect.selectByValue(handler);
    }
    driver.findElement(By.id("start")).click();

    // Wait test result, watching field "status" (TIMEOUT seconds at the
    // most)
View Full Code Here

                final PListBox listBox1 = get("listBox1");
                listBox1.setSelectedItem("Item 5");
            }
        });

        Select select = new Select(listBox1);
        final WebElement selectedOption = select.getFirstSelectedOption();
        Assert.assertEquals("Item 5", selectedOption.getText());
        Assert.assertEquals("Item 5", plistBox1.getSelectedItem());

        // clear
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PListBox listBox1 = get("listBox1");
                listBox1.clear();
            }
        });

        select = new Select(listBox1);
        Assert.assertEquals(0, select.getOptions().size());
        Assert.assertEquals(0, plistBox1.getItemCount());
        Assert.assertEquals(-1, plistBox1.getSelectedIndex());

    }
View Full Code Here

        Assert.assertEquals(new Long(3), plistBox2.getValue(2));
        Assert.assertEquals(new Long(4), plistBox2.getValue(3));
        Assert.assertEquals(new Long(5), plistBox2.getValue(4));
        Assert.assertEquals(new Long(6), plistBox2.getValue(5));

        final Select select2 = new Select(listBox2);
        select2.selectByIndex(4); // select item5

        final PChangeEvent e2 = eventsListener.poll();
        Assert.assertNotNull(e2);

        Assert.assertEquals(4, plistBox2.getSelectedIndex());
        Assert.assertEquals("Item 5", plistBox2.getSelectedItem());
        Assert.assertEquals(new Long(5), plistBox2.getSelectedValue());

        // remove
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PListBox listBox2 = get("listBox2");
                listBox2.removeItem("Item 2");
                listBox2.removeItem(2);
                listBox2.removeValue(new Long(6));
            }
        });

        options2 = listBox2.findElements(By.tagName("option"));

        Assert.assertEquals(3, options2.size());
        Assert.assertEquals("Item 1", options2.get(0).getText());
        Assert.assertEquals("Item 3", options2.get(1).getText());
        Assert.assertEquals("Item 5", options2.get(2).getText());

        Assert.assertEquals(3, plistBox2.getItemCount());
        Assert.assertEquals("Item 1", plistBox2.getItem(0));
        Assert.assertEquals("Item 3", plistBox2.getItem(1));
        Assert.assertEquals("Item 5", plistBox2.getItem(2));
        Assert.assertEquals(new Long(1), plistBox2.getValue(0));
        Assert.assertEquals(new Long(3), plistBox2.getValue(1));
        Assert.assertEquals(new Long(5), plistBox2.getValue(2));

        // server-side selection
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PListBox listBox2 = get("listBox2");
                listBox2.setSelectedValue(new Long(3)); // select item3
            }
        });

        final WebElement selectedOption2 = select2.getFirstSelectedOption();
        Assert.assertEquals("Item 3", selectedOption2.getText());
        Assert.assertEquals("Item 3", plistBox2.getSelectedItem());
        Assert.assertEquals(new Long(3), plistBox2.getSelectedValue());

        // TODO
View Full Code Here

  }

  protected void selectOptionByText(WebElement selectField, String optionText) {
    $(selectField).shouldBe(present);
    $(selectField).find(byText(optionText)).shouldBe(visible);
    new Select(selectField).selectByVisibleText(optionText);
  }
View Full Code Here

  }

  protected void selectOptionByValue(WebElement selectField, String optionValue) {
    $(selectField).shouldBe(present);
    $(selectField).find(byValue(optionValue)).shouldBe(visible);
    new Select(selectField).selectByValue(optionValue);
  }
View Full Code Here

    WebElement option = getSelectedOption(selectElement);
    return option == null ? null : option.getText();
  }

  protected SelenideElement getSelectedOption(WebElement selectElement) {
    return wrap(new Select(selectElement).getFirstSelectedOption());
  }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.support.ui.Select

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.