public void displayByRecipientQuestionGiver() {
   Select select =
       new Select(
           browser.driver.findElement(By.name(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE)));
   select.selectByVisibleText("Group by - Recipient > Question > Giver");
   waitForPageToLoad();
 }
Esempio n. 2
0
 public WebElementFacade selectByVisibleText(final String label) {
   waitUntilElementAvailable();
   Select select = new Select(webElement);
   select.selectByVisibleText(label);
   notifyScreenChange();
   return this;
 }
 @Test
 public void testSelect() {
   loadPage();
   Assert.assertEquals(3, select.getOptions().size());
   select.selectByIndex(0);
   Assert.assertEquals("option one", select.getFirstSelectedOption().getText());
 }
Esempio n. 4
0
  public static void main(String[] args) {
    // TODO Auto-generated method stu2) Close all the frames other than center -

    System.setProperty(
        "webdriver.chrome.driver",
        "C:\\Users\\Admin\\MyWorkspace\\SeleniumWebDriver\\chromedriver_win32\\chromedriver.exe");
    ChromeDriver driver = new ChromeDriver();
    driver.get("http://www.crystalcruises.com");
    String parentWindowHandle = driver.getWindowHandle();
    driver.findElementByLinkText("GUEST CHECK-IN").click();
    Set<String> allWindowHandles = driver.getWindowHandles();
    for (String windowHandle : allWindowHandles) {
      driver.switchTo().window(windowHandle);
    }
    driver.findElementByLinkText("click here").click();

    Set<String> allWndHandles = driver.getWindowHandles();
    for (String wndHandle : allWndHandles) {
      driver.switchTo().window(wndHandle);
    }
    Select dropdown = new Select(driver.findElementByClassName("goog-te-combo"));
    dropdown.selectByValue("ta");

    // Run configuration ->Common tab -> Other radio button -> UTF 8 -> Click Apply -> Click Run
    String text = driver.findElementByXPath("//*[@id='mainBody']/div[1]/div[2]").getText();
    System.out.println(text);

    // not getting tamil text?
  }
 public static void selectFilterAction(String dropDownSelection, String selectionValue) {
   // TODO Auto-generated method stub
   // Go to drop down
   Select filterAxnDropDown =
       new Select(Driver.Instance.findElement(By.cssSelector(dropDownSelection)));
   filterAxnDropDown.selectByVisibleText(selectionValue); // select the value as given	
 }
Esempio n. 6
0
  @Test
  public void makeapayment() throws Exception {
    tosignin();
    sleepfor(3);
    clickByCss("#start-pay-bill");
    sleepfor(2);
    clickByCss("#onetime_opt");
    clickByCss("#payment-method");
    sleepfor(4);
    // This is to select an option with text.
    // By.xpath(".//*[@id='payment-method']/option[@value='card']");

    Select selectBox = new Select(driver.findElement(By.id("payment-method")));
    selectBox.selectByVisibleText("card");
    // By.xpath(".//*[@id='payment-method']/option[@value=card']");
    // clickByXpath(".//*[@id='payment-method']/option[text() = 'Credit Card or Debit Card']");
    // clickByXpath(".//*[@id='payment-method']");

    sleepfor(2);
    // driver.findElement(By.cssSelector(""))
    // clickByCss("#onetime_opt");

    // clickByXpath(".//*[@id='confirm-billpay-type']");
    clickByCss("#confirm-billpay-type");
    // clickByCss(".cancel-link.pull-right"); //For the cancel option
    // clickByXpath(".//*[@id='agree-terms-checkbox']"); //Giving some trouble for the clicking
    //        clickByCss("#agree-terms");
    //        clickByCss(".button");
    //        clickByCss(".selected");
    //        sleepfor(2);
    //        tosignout();

  }
Esempio n. 7
0
 /**
  * Select theme and apply selected one
  *
  * @param theme ThemeType
  * @return {@link AdminConsolePage}
  */
 public HtmlPage selectTheme(ThemeType theme) throws TimeoutException, InterruptedException {
   checkNotNull(theme.text);
   Select themeType = new Select(driver.findElement(THEME_MENU_SELECT));
   themeType.selectByValue(theme.text);
   clickApplyButton();
   return getCurrentPage();
 }
  protected static void selectByRegexpValue(
      WebDriver webDriver, String selectLocator, String regexp) {

    WebElement webElement = getWebElement(webDriver, selectLocator);

    Select select = new Select(webElement);

    List<WebElement> optionWebElements = select.getOptions();

    Pattern pattern = Pattern.compile(regexp);

    int index = -1;

    for (WebElement optionWebElement : optionWebElements) {
      String optionWebElementValue = optionWebElement.getAttribute("value");

      Matcher matcher = pattern.matcher(optionWebElementValue);

      if (matcher.matches()) {
        index = optionWebElements.indexOf(optionWebElement);

        break;
      }
    }

    select.selectByIndex(index);
  }
  @Test(expected = NoSuchElementException.class)
  public void shouldThrowANoSuchElementExceptionIfNothingIsSelected() {
    WebElement selectElement = driver.findElement(By.name("select_empty_multiple"));
    Select select = new Select(selectElement);

    select.getFirstSelectedOption();
  }
 private static void verifySelectFieldIsDefault(String selector, WebDriver driver) {
   String xpath = "//select[contains(@class, '" + selector + "')]";
   for (WebElement element : driver.findElements(By.xpath(xpath))) {
     Select select = new Select(element);
     assertEquals(select.getFirstSelectedOption(), select.getOptions().get(0));
   }
 }
Esempio n. 11
0
 private void SpecialNeeds() throws IOException {
   // Click Special Needs
   driver
       .findElement(
           By.xpath(
               "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Special Needs\")]"))
       .click();
   // Select Special Needs
   Select SpecialNeeds = new Select(driver.findElement(By.id("edit-special-needs")));
   // Select Learning Center
   SpecialNeeds.selectByVisibleText("Learning Center");
   // Select Early Syllabus
   SpecialNeeds.selectByVisibleText("Early syllabus");
   // Click Apply
   driver.findElement(By.id("edit-special-needs-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
  private Slave create(String host, Jenkins j) {
    // Just to make sure the dumb slave is set up properly, we should seed it
    // with a FS root and executors
    final DumbSlave s = j.slaves.create(DumbSlave.class);

    s.find(by.input("_.host")).sendKeys(host);

    sleep(25);

    final Select cId = new Select(s.find(by.input("_.credentialsId")));
    final String credentialName = String.format("%s (%s)", machine.getUser(), fingerprint);
    s.waitForCond(
        new Callable<Object>() {
          @Override
          public Object call() throws Exception {
            List<WebElement> options = cId.getOptions();
            for (WebElement e : options) {
              if (credentialName.equals(e.getText())) return true;
            }
            return false;
          }
        });
    cId.selectByVisibleText(credentialName);
    s.setExecutors(1);

    s.save();
    return s;
  }
  @When("^틴캐시 결제수단을 선택한다$")
  public void 틴캐시_결제수단을_선택한다() throws Throwable {
    // 라디오 버튼 사용으로 상품권 선택
    WebElement petrol =
        driver.findElement(
            By.xpath("//*[@id='common']/table/tbody/tr[2]/td/ul[2]/li[1]/span/input"));

    if (!petrol.isSelected()) petrol.click();

    assertTrue(petrol.isSelected());

    // 라디오 그룹 자동화 테스트
    List<WebElement> fuel_type = (List<WebElement>) driver.findElements(By.name("spgid"));
    for (WebElement type : fuel_type) {
      if (type.getAttribute("value").equals("gift")) {
        if (!type.isSelected()) type.click();
        assertTrue(type.isSelected());
        break;
      }
    }

    Select make = new Select(driver.findElement(By.name("spgid_gift")));
    assertFalse(make.isMultiple());
    make.selectByVisibleText("틴캐시");
    assertEquals("틴캐시", make.getFirstSelectedOption().getText());
  }
 private static void updateSelectFieldtoDefault(String selector, WebDriver driver) {
   String xpath = "(//select)[contains(@class, '" + selector + "')]";
   for (WebElement element : driver.findElements(By.xpath(xpath))) {
     Select select = new Select(element);
     select.selectByIndex(0);
     new WebDriverWait(driver, 10).until(elementToBeSelected(select.getOptions().get(0)));
   }
 }
Esempio n. 15
0
 public boolean isTextEqualInDropdown(Supplier<By> by, String text) {
   final Element element = untilFound(by);
   Select dropdown = new Select(element);
   return dropdown
       .getOptions()
       .parallelStream()
       .anyMatch(opt -> opt.getText().equals(text.trim()));
 }
Esempio n. 16
0
 public WebElementFacade selectByIndex(int indexValue) {
   enableHighlightingIfRequired();
   waitUntilElementAvailable();
   Select select = new Select(webElement);
   select.selectByIndex(indexValue);
   notifyScreenChange();
   return this;
 }
Esempio n. 17
0
 @Test
 public void shouldAllowOptionsToBeSelectedByReturnedValue() {
   WebElement selectElement = driver.findElement(By.name("select_empty_multiple"));
   Select select = new Select(selectElement);
   select.selectByValue("select_2");
   WebElement firstSelected = select.getFirstSelectedOption();
   assertEquals("select_2", firstSelected.getText());
 }
Esempio n. 18
0
  @Test
  public void shouldAllowOptionsToBeDeselectedByReturnedValue() {
    WebElement selectElement = driver.findElement(By.name("multi"));
    Select select = new Select(selectElement);
    select.deselectByValue("eggs");
    List<WebElement> returnedOptions = select.getAllSelectedOptions();

    assertEquals(1, returnedOptions.size());
  }
Esempio n. 19
0
  @Test
  public void shouldAllowUserToDeselectOptionsByVisibleText() {
    WebElement selectElement = driver.findElement(By.name("multi"));
    Select select = new Select(selectElement);
    select.deselectByVisibleText("Eggs");
    List<WebElement> returnedOptions = select.getAllSelectedOptions();

    assertEquals(1, returnedOptions.size());
  }
Esempio n. 20
0
  @Test
  public void shouldReturnFirstSelectedOption() {
    WebElement selectElement = driver.findElement(By.name("multi"));
    Select select = new Select(selectElement);

    WebElement firstSelected = select.getFirstSelectedOption();

    assertEquals("Eggs", firstSelected.getText());
  }
 private static void verifySelectFieldOptionSelected(
     String selector, String expectedValue, WebDriver driver) {
   String xpath = "//select[contains(@class, '" + selector + "')]";
   List<WebElement> selects = driver.findElements(By.xpath(xpath));
   for (WebElement element : selects) {
     Select select = new Select(element);
     assertTrue(select.getFirstSelectedOption().getText().contains(expectedValue));
   }
 }
Esempio n. 22
0
  public static void ArrivalCity(WebDriver driver) {
    log.info("Invoking the ArrivalCity method");

    Select sel5 = new Select(driver.findElement(By.name("arrive")));

    log.info("Selecting ArrivalCity from drop down");

    sel5.selectByVisibleText("London");
  }
Esempio n. 23
0
  public static void DepartureCity(WebDriver driver) {
    log.info("Invoking the DepartureCity method");

    Select sel4 = new Select(driver.findElement(By.name("depart")));

    log.info("Selecting DepartureCity from drop down");

    sel4.selectByVisibleText("New York");
  }
Esempio n. 24
0
 public List<Integer> getAllSelectedIndices(Supplier<By> by) {
   Select select = new Select(findElement(by));
   List<WebElement> options = select.getOptions();
   return select
       .getAllSelectedOptions()
       .stream()
       .map(options::indexOf)
       .collect(Collectors.toList());
 }
 @Override
 protected String applyOnElement(WebElement element) {
   Select select = new Select(element);
   String text = select.getFirstSelectedOption().getText();
   if (text == null) {
     this.message = "No option selected";
     return null;
   }
   return text;
 }
 /**
  * Select an '<option>' in a all '<select>' containing @param selector in their id by its text
  *
  * @param selector class partial of the field to be updated
  * @param visibleText the text of the option to select
  */
 private static void updateSelectFieldLocatedByClass(
     String selector, String visibleText, WebDriver driver) {
   String xpath = "(//select)[contains(@class, '" + selector + "')]";
   for (WebElement element : driver.findElements(By.xpath(xpath))) {
     Select select = new Select(element);
     select.selectByVisibleText(visibleText);
     WebElement option = element.findElement(By.xpath("//option[text()='" + visibleText + "']"));
     new WebDriverWait(driver, 10).until(elementToBeSelected(option));
   }
 }
Esempio n. 27
0
  @Test
  public void shouldAllowOptionsToBeSelectedFromTheSelectElementThatIsNarrowerThanOptions() {
    driver.get(pages.selectPage);
    WebElement selectElement = driver.findElement(By.id("narrow"));
    Select select = new Select(selectElement);
    select.selectByIndex(1);
    List<WebElement> returnedOptions = select.getAllSelectedOptions();

    assertEquals(1, returnedOptions.size());
  }
Esempio n. 28
0
  @Test
  @Ignore(MARIONETTE)
  public void shouldAllowUserToDeselectAllWhenSelectSupportsMultipleSelections() {
    WebElement selectElement = driver.findElement(By.name("multi"));
    Select select = new Select(selectElement);
    select.deselectAll();
    List<WebElement> returnedOptions = select.getAllSelectedOptions();

    assertEquals(0, returnedOptions.size());
  }
  public void lance(String usuario, double valor) {
    WebElement txtValor = driver.findElement(By.name("lance.valor"));
    WebElement combo = driver.findElement(By.name("lance.usuario.id"));
    Select cbUsuario = new Select(combo);

    cbUsuario.selectByVisibleText(usuario);
    txtValor.sendKeys(String.valueOf(valor));

    driver.findElement(By.id("btnDarLance")).click();
  }
 public void filterResponsesForAllSections() {
   Select select =
       new Select(
           browser
               .driver
               .findElements(By.name(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION))
               .get(1));
   select.selectByVisibleText("All");
   waitForPageToLoad();
 }