/**
   * Fills an autocomplete field with a given value.
   *
   * @param driver The WebDriver instance we are working with
   * @param value The new value, or null to generate a non-empty value
   * @param autocompleteInputElement The WebElement into which we are inputting the value
   */
  public static void fillAutocompleteField(
      WebDriver driver, WebElement autocompleteInputElement, String value) {

    if (autocompleteInputElement != null) {
      autocompleteInputElement.click();
      autocompleteInputElement.sendKeys(value);

      new WebDriverWait(driver, 10)
          .until(
              ExpectedConditions.visibilityOfElementLocated(By.className("cs-autocomplete-popup")));

      WebElement popupElement = driver.findElement(By.className("cs-autocomplete-popup"));
      WebElement matchesElement =
          popupElement.findElement(By.className("csc-autocomplete-Matches"));
      WebElement matchSpanElement = null;

      new WebDriverWait(driver, 10)
          .until(
              ExpectedConditions.visibilityOfElementLocated(By.className("cs-autocomplete-popup")));

      for (WebElement candidateMatchElement : matchesElement.findElements(By.tagName("li"))) {
        WebElement candidateMatchSpanElement =
            candidateMatchElement.findElement(By.tagName("span"));

        if (candidateMatchSpanElement.getText().equals(value)) {
          matchSpanElement = candidateMatchSpanElement;
          break;
        }
      }

      if (matchSpanElement != null) {
        // Click the value if found
        new WebDriverWait(driver, 10)
            .until(
                ExpectedConditions.visibilityOfElementLocated(
                    By.className("cs-autocomplete-popup")));

        matchSpanElement.click();

      } else {
        // create a new authority item if one matching it does not already exist
        new WebDriverWait(driver, 10)
            .until(
                ExpectedConditions.visibilityOfElementLocated(
                    By.className("cs-autocomplete-popup")));

        WebElement addToPanelElement =
            popupElement.findElement(By.className("csc-autocomplete-addToPanel"));
        WebElement firstAuthorityItem = addToPanelElement.findElement(By.tagName("li"));

        firstAuthorityItem.click();

        while (findElementsWithTimeout(driver, 0, By.className("cs-autocomplete-popup")).size()
            > 0) {
          // Wait for the popup to close
        }
      }
    } else {
    }
  }
  @Test
  @RunAsClient
  @InSequence(3000)
  public void checkRequiredFieldsAndCancel() throws Exception {

    firstNameField.clear();
    middleNameField.clear();
    lastNameField.clear();
    emailAddressField.clear();
    jobTitleField.clear();
    submitButton.click();

    waitForElement(browser, firstNameFieldErrorXpath);

    logger.log(
        Level.INFO, "firstNameFieldError.isDisplayed() = " + firstNameFieldError.isDisplayed());
    assertTrue(
        "The First Name Validation Error should be displayed on the page at this point but it is not.",
        firstNameFieldError.isDisplayed());
    logger.log(
        Level.INFO, "lastNameFieldError.isDisplayed() = " + lastNameFieldError.isDisplayed());
    assertTrue(
        "The Last Name Validation Error should be displayed on the page at this point but it is not.",
        lastNameFieldError.isDisplayed());
    logger.log(
        Level.INFO,
        "emailAddressFieldError.isDisplayed() = " + emailAddressFieldError.isDisplayed());
    assertTrue(
        "The Email Address Validation Error should be displayed on the page at this point but it is not.",
        emailAddressFieldError.isDisplayed());

    cancelButton.click();
  }
  public void addProductFromCategory() {
    SelectSportProduct.click();
    Utils.sleep(1);

    AddToBasket.click();
    Utils.sleep(1);
  }
Пример #4
0
 /*Admin Login*/
 public void admin(String userAd, String passAd) {
   driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
   siteAdmin.click();
   userFieldAdmin.sendKeys(userAd);
   passFieldAdmin.sendKeys(passAd);
   loginButtonAdmin.click();
 }
Пример #5
0
  public void pesquisaPedido(WebDriver driver) throws InterruptedException {
    this.driver = driver;
    driver.get("http://*****:*****@id='btnPesquisar']/span[2]"));
    btnPesquisa.click();
  }
Пример #6
0
 /**
  * delete folder helper function
  *
  * @param id of folder to be deleted
  */
 protected void deleteFolder(String id) {
   WebElement editBtn = driver.findElement(By.linkText("Edit"));
   editBtn.click();
   WebElement deleteBtn =
       driver.findElement(By.xpath("//a[@href='/delete_folder?folder=" + id + "']"));
   deleteBtn.click();
 }
Пример #7
0
  // set billing address
  public void setBillingAddress(AMPTestData billingaddress) {

    // vehicleType.get().selectByValue(dealerInfo.getDealerInfo_vehicletype());
    String Checkboxonoff = billingaddress.getPaymentInfo_billinsameasprimaryonoff().toLowerCase();
    if (Checkboxonoff == "on") {
      if (!CheckBox_BillingAsPrimary.isSelected()) {
        // Checking the checkbox
        CheckBox_BillingAsPrimary.click();
      }
    } else if (Checkboxonoff == "off") {
      if (CheckBox_BillingAsPrimary.isSelected()) {
        // Unchecking the checkbox
        CheckBox_BillingAsPrimary.click();
        // Entering the Address details
        DropDown_CCPrefix.get().selectByValue(billingaddress.getPaymentInfo_prefix());
        Input_CCFirstName.enterText(billingaddress.getPaymentInfo_firstname());
        Input_CCLastName.enterText(billingaddress.getPaymentInfo_lastname());
        Dropdown_CCCountry.get().selectByValue(billingaddress.getPaymentInfo_country());
        Input_CCAddress1.enterText(billingaddress.getPaymentInfo_address1());
        Input_CCAddress2.enterText(billingaddress.getPaymentInfo_address2());
        Input_CCCity.enterText(billingaddress.getPaymentInfo_city());
        DropDown_CCState.get().selectByValue(billingaddress.getPaymentInfo_state());
        Input_CCZip.enterText(billingaddress.getPaymentInfo_zipcode());
      }
    }
  }
  @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 String addFolderAction(String folderToCreate) throws InterruptedException {

    TimeUnit.SECONDS.sleep(2);

    executeJavascript("document.getElementsByClassName('edit_me')[0].click();");
    TimeUnit.SECONDS.sleep(2);

    WebElement txtName = getWebDriver().findElement(By.id("projects_milestone_title"));
    txtName.click();
    txtName.clear();
    txtName.sendKeys(folderToCreate);

    List<WebElement> saveBtnList =
        getWebDriver().findElements(By.xpath(".//*[@id='projects_milestone_submit_action']/input"));
    for (WebElement btnSave : saveBtnList) {
      if (btnSave.isDisplayed()) btnSave.click();
    }

    TimeUnit.SECONDS.sleep(1);
    String name = "";
    List<WebElement> txtist = getWebDriver().findElements(By.cssSelector(".element-plain-text"));
    for (WebElement title : txtist) {
      if (title.getText().equals(folderToCreate)) {
        name = title.getText();
        break;
      }
    }
    return name;
  }
  protected String addTextToDesc(String toolBarXPath, String descToTest)
      throws InterruptedException {

    WebElement descriptionToolBar = getWebDriver().findElement(By.xpath(toolBarXPath));

    TimeUnit.SECONDS.sleep(2);

    WebElement textLoader = descriptionToolBar.findElement(By.cssSelector(".text.load"));
    textLoader.click();

    writeInRedactor(descToTest);

    WebElement saveDescription =
        driverWait.until(
            ExpectedConditions.visibilityOfElementLocated(By.xpath(".//*[@title='Save']")));
    saveDescription.click();

    WebElement text =
        driverWait.until(
            ExpectedConditions.visibilityOfElementLocated(
                By.xpath(".//*[starts-with(@id,'form_for_textarea_')]/span")));
    String description = text.getText();

    return description;
  }
  protected void selectOptionByLabel(WebElement menuElement, String text, boolean guardAjax) {
    String menuId = getEscapedElementId(menuElement);
    WebElement trigger = menuElement.findElement(By.cssSelector("div.ui-selectonemenu-trigger"));
    trigger.click();

    String menuItemsContainerId = menuId + "_panel";
    List<WebElement> options =
        driver.findElements(
            By.cssSelector("#" + menuItemsContainerId + " tr.ui-selectonemenu-item"));
    if (options.isEmpty()) {
      options =
          driver.findElements(
              By.cssSelector("#" + menuItemsContainerId + " li.ui-selectonemenu-item"));
    }
    String selectedOptionText = getSelectedOptionText(menuElement);
    for (WebElement option : options) {
      if (option.getAttribute("data-label").equals(text)) {
        if (guardAjax && !selectedOptionText.equals(text)) {
          Graphene.guardAjax(option).click();
        } else {
          option.click();
        }
        break;
      }
    }
  }
Пример #12
0
 public UsersGroupsBasePage createUser(
     String username,
     String firstname,
     String lastname,
     String company,
     String email,
     String password,
     String group)
     throws NoSuchElementException {
   usernameInput.sendKeys(username);
   firstnameInput.sendKeys(firstname);
   lastnameInput.sendKeys(lastname);
   companyInput.sendKeys(company);
   emailInput.sendKeys(email);
   firstPasswordInput.sendKeys(password);
   secondPasswordInput.sendKeys(password);
   groupInput.sendKeys(group);
   WebElement ajaxUserListElement =
       findElementWithTimeout(
           By.xpath(
               "//table[@id='createUser:nxl_user:nxw_groups_suggestionBox:suggest']/tbody/tr[1]/td[2]"));
   ajaxUserListElement.click();
   createButton.click();
   return asPage(UsersGroupsBasePage.class);
 }
Пример #13
0
  public void testAwsppWebDriver(int docs, int times) throws InterruptedException {
    init();
    WebDriver driver = new FirefoxDriver();
    //		WebDriver driver = new HtmlUnitDriver();
    for (int j = 0; j < times; j++) {
      driver.get(baseUrl);
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      // create/resume transaction

      WebElement docs_input = driver.findElement(By.id("create_docs_1"));
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      docs_input.clear();
      docs_input.sendKeys("" + docs);

      WebElement createButton = driver.findElement(By.id("resume"));
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      createButton.click();
      for (int i = 0; i < docs; i++) {

        WebElement img = driver.findElement(By.xpath("//img[@alt='Click to sign']"));
        driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
        img.click();

        WebElement submitButton = driver.findElement(By.name("button"));
        driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);

        submitButton.click();
      }
      WebElement link = driver.findElement(By.linkText("Go Back to Parent Page"));
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      link.click();
    }
    driver.close();
  }
  public String addNewProject(String projectName) throws InterruptedException {

    WebElement btnNewProj =
        driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.id("new_project")));

    btnNewProj.click();
    TimeUnit.SECONDS.sleep(2);

    executeJavascript("document.getElementsByClassName('edit_me')[0].click();");
    TimeUnit.SECONDS.sleep(2);

    WebElement txtName = getWebDriver().findElement(By.id("projects_project_title"));
    txtName.click();
    txtName.clear();
    txtName.sendKeys(projectName);

    List<WebElement> saveBtnList =
        getWebDriver().findElements(By.xpath(".//*[@id='projects_project_submit_action']/input"));
    for (WebElement btnSave : saveBtnList) {
      if (btnSave.isDisplayed()) btnSave.click();
    }

    TimeUnit.SECONDS.sleep(1);
    String name = "";
    List<WebElement> txtist = getWebDriver().findElements(By.cssSelector(".element-plain-text"));
    for (WebElement title : txtist) {
      if (title.getText().equals(projectName)) {
        name = title.getText();
        break;
      }
    }
    return name;
  }
  /**
   * 编辑病例
   *
   * @param age
   * @return
   */
  public static String editCase(String age) {
    WebElement eEditBtn = driver.findElement(By.id(edit_case_btn));
    eEditBtn.click();

    WebElement eAgeYear = driver.findElement(By.id(age_year_input));
    eAgeYear.clear();
    eAgeYear.sendKeys(age);

    boolean flag = Utils.swipe(driver, By.id(pub_case), 2);
    if (flag) {
      WebElement eEditCase = driver.findElement(By.id(pub_case));
      eEditCase.click();
    } else {
      Assertion.assertEquals(true, flag, "发布按钮未找到,请检查后再试!");
    }

    String terminalAge = "";
    boolean findCaseAge = Utils.isElementExist(driver, By.id(terminal_age));
    int num = 0;
    if (findCaseAge == false) {
      while (findCaseAge == false && num < 10) {
        findCaseAge = Utils.isElementExist(driver, By.id(terminal_age));
        System.out.println(num);
        if (findCaseAge) {
          terminalAge = Utils.getText(driver, By.id(terminal_age));
        } else {
          num++;
        }
      }
    } else {
      terminalAge = Utils.getText(driver, By.id(terminal_age));
    }

    return terminalAge;
  }
  @Test
  public void shouldManageMenu() {

    for (WebElement e : findElementsBySelector(escapeClientId("form:menu") + " .ui-button")) {

      WebElement hidden = findElementBySelector(e, "input[type='checkbox']");

      assertTrue("Should not be actived with unchecked", !hasClass(e, "ui-state-active"));
      assertTrue("Hidden value should be valid.", !hidden.isSelected());

      e.click();

      assertTrue("Should be actived by selection.", hasClass(e, "ui-state-active"));
      assertTrue("Hidden value should change.", hidden.isSelected());

      e.click();

      assertTrue("Should remove active state.", !hasClass(e, "ui-state-active"));
      assertTrue("Hidden value should change.", !hidden.isSelected());

      e.click();
    }

    findElementById("form:submit").click();

    waitUntilAjaxRequestCompletes();

    WebElement dialog = findElementById("form:dialog");

    assertTrue("Should display result dialog.", dialog.isDisplayed());

    assertTrue(
        "Should display valid results.",
        findElementsBySelector(dialog, ".ui-datalist-item").size() == 3);
  }
  protected boolean addTable(WebElement procedureDescToolBar, String data)
      throws InterruptedException {

    boolean created;
    WebElement tableLoader = procedureDescToolBar.findElement(By.cssSelector(".grid.load"));
    tableLoader.click();

    TimeUnit.SECONDS.sleep(4);

    writeInTable(data);

    TimeUnit.SECONDS.sleep(2);

    WebElement imgSaveDesc =
        driverWait.until(
            ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".fa.fa-check")));
    imgSaveDesc.click();
    TimeUnit.SECONDS.sleep(4);

    driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".delete_me")));

    String value = readFromTable();

    WebElement tableArea =
        driverWait.until(
            ExpectedConditions.visibilityOfElementLocated(
                By.cssSelector(".inline_form_container.type_excel.spreadJS_activated")));

    created = ((tableArea != null) && (data.equals(value)));
    return created;
  }
  public MainPage confirmDeleteProject(String projectName) {

    deleteConfirmButton.click();
    projectNameInput.sendKeys(projectName);
    submitDeleteButton.click();
    return new MainPage();
  }
  @Then("^틴캐시 결제수단 한도 알럿이 노출된다$")
  public void 틴캐시_결제수단_한도_알럿이_노출된다() throws Throwable {
    // Assert.assertTrue(driver.getTitle().contains("//*[@id='error_msg_desc1']"));

    String parentWindowId = driver.getWindowHandle();

    Set<String> allWindows = driver.getWindowHandles();
    if (!allWindows.isEmpty()) {
      for (String windowID : allWindows) {
        driver.switchTo().window(windowID);
        if (driver.getPageSource().contains("확인해주세요")) {
          try {
            WebElement noMoreButton = driver.findElement(By.xpath("//*[@id='errorPopup1']"));
            noMoreButton.click();

            WebElement identifyButton =
                driver.findElement(By.xpath("//*[@id='errorPopup1']/div/p/a/img"));

            identifyButton.click();
            break;
          } catch (NoSuchWindowException e) {
            e.printStackTrace();
          }
        }
      }
    }

    driver.switchTo().window(parentWindowId);
  }
  public static void main(String[] args) throws Exception {

    IPhoneDriver driver = new IPhoneDriver("http://192.168.0.39:3001/hub/");

    driver.get("http://orangeworld.co.uk/");
    System.out.println(driver.getCurrentUrl());

    WebElement MenuTab = driver.findElementByXPath(Constants.MenuTab);
    MenuTab.isDisplayed();
    MenuTab.click();
    Thread.sleep(3000);
    // Menu Content Entertainment
    WebElement MenuContent_Entertainment =
        driver.findElementByXPath(Constants.MenuContent_Entertainment);
    MenuContent_Entertainment.isDisplayed();
    MenuContent_Entertainment.click();

    WebElement MenuContent_Entertainment_BreadCrumb =
        driver.findElementByXPath(Constants.MenuContent_Entertainment_BreadCrumb);
    MenuContent_Entertainment_BreadCrumb.isDisplayed();
    System.out.println("BreadCrumb Name is " + MenuContent_Entertainment_BreadCrumb.getText());

    WebElement Entertainment_Homepage = driver.findElementByXPath(Constants.Entertainment_Homepage);
    Entertainment_Homepage.isDisplayed();
    Entertainment_Homepage.click();
    System.out.println(driver.getCurrentUrl());

    System.out.println("Test pass");

    driver.quit();
  }
  public FloorLandingPage SelectAll_checkbox() throws InterruptedException {
    // GenericClass.CheckBox_Count(select);
    GenericClass.selectElement(ViewDropdown_section, "All");
    GenericClass.ActionOnAlert("Accept");
    for (int i = 0; i <= All_Checkboxes.size() - 1; i++) {
      WebElement we = All_Checkboxes.get(i);
      we.click();
      boolean check = we.isSelected();
      if (check == true) {
        System.out.println("All selected");
      } else {
        System.out.println("not selected");
      }
    }
    Thread.sleep(5000);

    for (int i = 0; i <= All_Checkboxes.size() - 1; i++) {
      WebElement we = All_Checkboxes.get(i);
      we.click();
      boolean check = we.isSelected();
      if (!check == true) {
        System.out.println("All deselected");
      } else {
        System.out.println("selected");
      }
    }
    return FLP;
  }
Пример #22
0
 @ExcludeBrowsers({BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET})
 public void testUpdateOnAttribute_UsingStringSource() throws Exception {
   String event = "blur";
   String baseTag =
       "<aura:component  model=\"java://org.auraframework.components.test.java.model.TestJavaModel\"> "
           + "<div id=\"%s\">"
           + event
           + ":"
           + "<ui:inputText aura:id=\"%s\" class=\"%s\" value=\"{!m.string}\" updateOn=\"%s\"/>"
           + "</div>"
           + "<div id=\"output\">"
           + "output: <ui:outputText value=\"{!m.string}\"/>"
           + "</div>"
           + "</aura:component>";
   DefDescriptor<ComponentDef> cmpDesc =
       addSourceAutoCleanup(ComponentDef.class, baseTag.replaceAll("%s", event));
   open(String.format("/%s/%s.cmp", cmpDesc.getNamespace(), cmpDesc.getName()));
   String value = getCurrentModelValue();
   WebElement input = auraUITestingUtil.findElementAndTypeEventNameInIt(event);
   WebElement outputDiv = findDomElement(By.id("output"));
   assertModelValue(value, "Value shouldn't be updated yet.");
   input.click();
   outputDiv.click(); // to simulate tab behavior for touch browsers
   assertModelValue(event); // value should have been updated
 }
Пример #23
0
 /*Method to click on "Visit API Page" button for AT&T U-verse Enabled*/
 public APIPage clickATTUVerseAPIPage() {
   apis.click();
   waitForPageToLoad();
   aTTUVerseAPIPage.click();
   waitForPageToLoad();
   validatePageTitle("Get AT&T U-verse® Enabled SDK");
   return this;
 }
Пример #24
0
 /*Method to click on "Visit API Page" button for AT&T Sponsored Data API*/
 public APIPage clickATTSponsoredDataAPIAPIPage() {
   apis.click();
   waitForPageToLoad();
   aTTSponsoredDataAPIAPIPage.click();
   waitForPageToLoad();
   validatePageTitle("AT&T Sponsored Data API | AT&T Developer");
   return this;
 }
Пример #25
0
 /*Method to click on "Visit API Page" button for AT&T Mobile Identity API Toolkit*/
 public APIPage clickATTMobileIdentityAPIToolkitAPIPage() {
   apis.click();
   waitForPageToLoad();
   aTTMobileIdentityAPIToolkitAPIPage.click();
   waitForPageToLoad();
   validatePageTitle("AT&T Mobile Identity API Toolkit | AT&T Developer");
   return this;
 }
Пример #26
0
 /*Method to click on "Documentation" button for Advertising*/
 public APIPage clickAdvertisingDocumentation() {
   apis.click();
   waitForPageToLoad();
   advertisingAPIDocumentation.click();
   waitForPageToLoad();
   validatePageTitle("Advertising Documentation");
   return this;
 }
Пример #27
0
 public ContactsPage deleteContact(String name) {
   TouchAction action = new TouchAction(wd);
   WebElement contact = getContactFieldByName(name);
   action.longPress(contact).release().perform();
   modalOptionDeleteContact.click();
   btnDeleteDeletePrompt.click();
   return this;
 }
Пример #28
0
 /*Method to click on "Documentation" button for Device Capabilities*/
 public APIPage clickDeviceCapabilitiesDocumentation() {
   apis.click();
   waitForPageToLoad();
   deviceCapabilitiesAPIDocumentation.click();
   waitForPageToLoad();
   validatePageTitle("Device Capabilities Documentation");
   return this;
 }
Пример #29
0
  public SharedBackupPage goToAllServers(WebDriver driver) {

    selectServersButton.click();
    WaitTool.waitForElementPresentAndVisible(driver, checkAllservers);
    checkAllservers.click();
    // addCartButton2.click();
    return this;
  }
Пример #30
0
 /*Method to click on "Documentation" button for Payment*/
 public APIPage clickPaymentDocumentation() {
   apis.click();
   waitForPageToLoad();
   paymentAPIDocumentation.click();
   waitForPageToLoad();
   validatePageTitle("Payment Documentation");
   return this;
 }