/**
   * Logs in to Showdown with the supplied information. Make password empty string if you wish to
   * use an unregistered account.
   */
  public void login(String userName, String password) {
    // Wait for the websocket connection to open...
    // This is technically waiting for the lobby window to initialise,
    // but this coincides with the socket opening so all G.
    waitForElementPresent(By.cssSelector("div.roomlist"));

    // If we store the By we risk accessing a stale element...
    String loginCssSelector = "button[name='login']";
    waitForElementPresent(By.cssSelector(loginCssSelector), 20);

    clickAt(By.cssSelector(loginCssSelector));
    WebElement usernameTextbox = driver.findElement(By.cssSelector("input[name='username']"));
    usernameTextbox.clear();
    usernameTextbox.sendKeys(userName);
    clickAt(By.cssSelector("button[type='submit']"));

    if (password.length() > 0) {
      waitForElementPresent(By.cssSelector("input[name='password']"));

      WebElement passwordTextbox = driver.findElement(By.cssSelector("input[name='password']"));
      passwordTextbox.clear();
      passwordTextbox.sendKeys(password);
      clickAt(By.cssSelector("button[type='submit']"));
    }
    currentUser = userName;
  }
  @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 TemplateProviderInlinePage createTemplateProvider(String space, String page) {
   spaceInput.clear();
   spaceInput.sendKeys(space);
   pageInput.clear();
   pageInput.sendKeys(page);
   createButton.click();
   return new TemplateProviderInlinePage();
 }
 /**
  * @param username
  * @param password
  * @return DevPage object
  */
 public DevPage loginAs(String username, String password) {
   usernameIB.clear();
   usernameIB.sendKeys(username);
   passwordIB.clear();
   passwordIB.sendKeys(password);
   submitBtn.click();
   return PageFactory.initElements(driver, DevPage.class);
 }
  public void updateAccountInformation(String firstName, String lastName) {
    firstNameInput.clear();
    firstNameInput.sendKeys(firstName);

    lastNameInput.clear();
    lastNameInput.sendKeys(lastName);

    submitButton.click();
  }
Beispiel #6
0
  public void login(String username, String password) {
    usernameInput.clear();
    usernameInput.sendKeys(username);

    passwordInput.clear();
    passwordInput.sendKeys(password);

    submitButton.click();
  }
 public void update(String firstName, String lastName, String email) {
   firstNameInput.clear();
   firstNameInput.sendKeys(firstName);
   lastNameInput.clear();
   lastNameInput.sendKeys(lastName);
   emailInput.clear();
   emailInput.sendKeys(email);
   submitButton.click();
 }
Beispiel #8
0
 /*Edit Site Settings from HomePage*/
 public void siteEdit(String siteNameText, String meta, String metaK) {
   siteSettings.click();
   siteNameLabel.clear();
   siteNameLabel.sendKeys(siteNameText);
   metaDescr.clear();
   metaDescr.sendKeys(meta);
   metaKeys.clear();
   metaKeys.sendKeys(metaK);
   saveSiteSettings.click();
 }
 public void TypeLoginPassword(String sLogin, String sPassword) throws ExceptFailTest {
   inputLogin.clear();
   inputLogin.sendKeys(sLogin);
   wLog.WriteString(1, "Вводим логин");
   System.out.println("Вводим логин");
   inputPassword.clear();
   inputPassword.sendKeys(sPassword);
   wLog.WriteString(1, "Вводим пароль");
   System.out.println("Вводим пароль");
 }
Beispiel #10
0
 /*Edit Article from Control Panel*/
 public void editArtCP(String labelArt, String datee) throws InterruptedException {
   articleMangerCP.click();
   articleClickToEdit.click();
   Thread.sleep(5000);
   toggleEdfromCP.click();
   editLabelArt.clear();
   editLabelArt.sendKeys(labelArt);
   publish.click();
   FinishPub.clear();
   FinishPub.sendKeys(datee);
   saveEditArt.click();
 }
Beispiel #11
0
 /*Edit Template Settings from HomePage*/
 public void edit(String colour, String bkColour, String frontTitle, String descrpt) {
   templateSettings.click();
   temColour.clear();
   temColour.sendKeys(colour);
   backColour.clear();
   backColour.sendKeys(bkColour);
   titleFront.clear();
   titleFront.sendKeys(frontTitle);
   description.clear();
   description.sendKeys(descrpt);
   saveColour.click();
 }
Beispiel #12
0
  public void checkPayOutErrorMsg(String payTool, String wallet, String sum, String errorMsg) {
    menuPage = new MenuPage();
    menuPage.clickCashPage();
    waitSleep(1500);
    Driver.get().switchTo().frame(Driver.get().findElement(By.cssSelector("#iframeBank + iframe")));

    // paymentHistoryBtn.click();

    // depositBtn.click();

    payOutBtn.click();
    switch (payTool) {
      case "qiwi":
        qiwiBtn.click();
        break;
      case "skrill":
        skrillBtn.click();
        break;
      case "webMoney":
        webMoneyBtn.click();
        break;
      case "yandex":
        yandexBtn.click();
        break;
      case "moneta":
        monetaBtn.click();
        break;
      default:
        throw new AssertionError("unsupported payTool identifier");
    }

    // #customerWalletFld.clear();
    // #customerWalletFld.sendKeys(wallet);
    customerWalletFld.clear();

    setTextJS(customerWalletFld, wallet);
    // *customerWalletFld.click();
    // *customerWalletFld.sendKeys(Keys.END);

    // #payOutAmountFld.clear();
    // #waitSleep(200);
    // #payOutAmountFld.sendKeys(sum);
    // *customerWalletFld.click();
    payOutAmountFld.clear();
    // #amountFld.sendKeys(sumToPay);
    setTextJS(payOutAmountFld, sum);
    payOutAmountFld.click();
    payOutAmountFld.sendKeys(Keys.END);

    getMoneyBtn.click();

    Assert.assertEquals(noMoneyMsg.getText(), errorMsg, "Error message was not as expected");
  }
 @Test
 public void testUntitled2() throws Exception {
   driver.get(baseUrl + "php4dvd/");
   WebElement userNameWebEdit = driver.findElement(By.id("username"));
   WebElement passwordWebEdit = driver.findElement(By.name("password"));
   WebElement subminButton = driver.findElement(By.name("submit"));
   userNameWebEdit.clear();
   userNameWebEdit.sendKeys("admin");
   passwordWebEdit.clear();
   passwordWebEdit.sendKeys("admin");
   subminButton.click();
 }
 public static void main(String[] args) {
   InternetExplorerVar ieVar = new InternetExplorerVar();
   LoggingIn.doItHere(ieVar);
   WebDriver driver = ieVar.getDriver();
   WebElement element;
   driver.get(ieVar.getBaseURL() + "/pages/setup/department/department_list.aspx");
   element = driver.findElement(By.id("key"));
   element.clear();
   element.sendKeys(new String[] {"ANDRPRGR"});
   element = driver.findElement(By.id("filter"));
   element.clear();
   element.sendKeys(new String[] {"Andrey\'s Providers"});
   element = driver.findElement(By.id("search_btn"));
   element.click();
   for (int i = 0; true; i++) {
     try {
       Thread.sleep(5);
     } catch (InterruptedException e) {
       continue;
     }
     if (i == 200) {
       return;
     }
     try {
       element = driver.findElement(By.xpath("//div[@id=\'list_list_body\']/div/div"));
       element.click();
     } catch (NoSuchElementException e) {
       continue;
     } catch (StaleElementReferenceException e) {
       continue;
     } catch (ElementNotVisibleException e) {
       continue;
     } catch (TimeoutException e) {
       i = 0;
       continue;
     }
     break;
   }
   String parentWindowHandler = driver.getWindowHandle();
   element = driver.findElement(By.id("list_delete_button"));
   element.click();
   try {
     while (true) {
       driver.switchTo().alert().accept();
     }
   } catch (NoAlertPresentException e) {
   }
   driver.switchTo().window(parentWindowHandler);
   Logout.doItHere(ieVar);
 }
Beispiel #15
0
 private static void val(WebDriver driver, WebElement element, String value) {
   if (isSelectTag(element)) {
     new Select(element).selectByValue(value);
   } else if (isInputTag(element) || isTextareaTag(element)) {
     if (isInputWithTypeWeDontChangeValue(element)) {
       String type = element.getAttribute("type");
       warnAboutNotChangingValue("<input type=\"" + type + "\">", "#my" + capitalize(type));
       return;
     }
     if (!isInputFileTag(element)) {
       element.clear();
     }
     element.sendKeys(value);
   } else if (isOptionTag(element)) {
     warnAboutNotChangingValue("<option>", "#myOption");
   } else if (isContentEditable(element)) {
     // #Cross-Driver
     if (DriverVersionUtils.getInstance().isHtmlUnitDriver(driver)) {
       changeContentEditableValueInHtmlUnit(driver, element, value);
     } else {
       if (driver instanceof FirefoxDriver) {
         // #Cross-Driver
         // in firefox, an editable div cannot be empty
         try {
           element.sendKeys(
               Keys.chord(Keys.CONTROL, Keys.HOME),
               Keys.chord(Keys.CONTROL, Keys.SHIFT, Keys.END));
           element.sendKeys(value);
         } catch (ElementNotVisibleException e) {
           // we could work it out, possibly via JavaScript, but we decided not to, as a user would
           // not be able to edit it!
           throw new ElementNotVisibleException(
               "Empty contenteditable elements are not visible in Firefox, "
                   + "so a user can't directly interact with them. Try picking an element before the contenteditable one "
                   + "and sending the TAB key to it, so the focus is switched, and then try calling .val() to change its value.",
               e);
         }
       } else {
         element.clear();
         element.sendKeys(value);
       }
     }
   } else {
     LOGGER.warn(
         "Function .val() called in element not known to be editable. Will attempt to send keys anyway. Element: "
             + element);
     element.clear();
     element.sendKeys(value);
   }
 }
Beispiel #16
0
  /**
   * 保存设备
   *
   * @param driver
   * @throws Exception
   * @creatTime 上午9:21:37
   * @author XuYi
   */
  protected void saveDevice(WebDriver driver) throws Exception {
    WebElement ip = driver.findElement(By.xpath(ipXpath));
    WebElement pwd = driver.findElement(By.xpath(pwdXpath));
    ip.clear();
    pwd.clear();
    ip.sendKeys("192.168.9.181");

    pwd.sendKeys("123");

    Thread.sleep(1000);

    WebElement save = driver.findElement(By.xpath(saveXpath));
    save.click();
    Thread.sleep(20 * 1000);
  }
Beispiel #17
0
  public ReviewOrderPage edit_account_from_order(WebDriver driver, AccountData data) {

    first_name_input.clear();
    first_name_input_invalid.sendKeys(data.getFirst_name2());
    last_name_input.clear();
    last_name_input_invalid.sendKeys(data.getLast_name2());
    company_input.clear();
    company_input.sendKeys(data.getCompany2());
    address_input.clear();
    address_input_invalid.sendKeys(data.getAddress2());
    city_input.clear();
    city_input_invalid.sendKeys(data.getCity2());
    save_edit_button.click();
    return PageFactory.initElements(driver, ReviewOrderPage.class);
  }
  @Test
  @DataSet(filename = "dataset/users/usersDataSet.xml", dataSourceBeanId = "dataSource")
  public void testPostEditUserFormValid() {
    log.debug("testPostEditUserFormValid");

    String firstName = "Uncle";
    String lastName = "Fester";

    openPageAndTestHeader("users/1/edit", "User Form");

    WebElement firstNameInput = driver.findElement(By.id("firstName"));
    Assert.assertNotNull(firstNameInput);
    firstNameInput.clear();
    firstNameInput.sendKeys(firstName);

    WebElement lastNameInput = driver.findElement(By.id("lastName"));
    Assert.assertNotNull(lastNameInput);
    lastNameInput.clear();
    lastNameInput.sendKeys(lastName);

    WebElement adminInput = driver.findElement(By.id("admin"));
    Assert.assertNotNull(adminInput);
    adminInput.click();

    WebElement submitButton = driver.findElement(By.cssSelector("form#userForm div.buttons input"));
    Assert.assertNotNull(submitButton);

    submitButton.click();

    confirmPageLoadAndTestHeader("View User");

    WebElement firstNameContainer =
        driver.findElement(By.xpath("/html/body/div/div[2]/div[2]/div[2]"));
    Assert.assertNotNull(firstNameContainer);
    Assert.assertTrue(firstNameContainer.getText().contains(firstName));

    WebElement lastNameContainer =
        driver.findElement(By.xpath("/html/body/div/div[2]/div[2]/div[3]"));
    Assert.assertNotNull(lastNameContainer);
    Assert.assertTrue(lastNameContainer.getText().contains(lastName));

    WebElement adminContainer = driver.findElement(By.xpath("/html/body/div/div[2]/div[2]/div[4]"));
    Assert.assertNotNull(adminContainer);
    Assert.assertTrue(adminContainer.getText().contains("false"));

    dbUnitDataSetTester.compareDataSetsIgnoreColumns(
        dataSource, "dataset/users/updatedUserDataSet.xml", "users", USERS_IGNORE_COLUMN_NAMES);
  }
  /**
   * 编辑病例
   *
   * @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;
  }
  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;
  }
  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;
  }
 public InstructorStudentListPage searchForStudent(String studentName) {
   searchBox.clear();
   searchBox.sendKeys(studentName);
   searchButton.click();
   waitForPageToLoad();
   return changePageType(InstructorStudentListPage.class);
 }
Beispiel #23
0
 private void setTargetContent(
     final long rowIndex, final String text, final String idFormat, final Plurals plural) {
   WebElement we = readyElement(By.id(String.format(idFormat, rowIndex, plural.index())));
   we.click();
   we.clear();
   we.sendKeys(text);
 }
 public EditProfilePage enterEmail(String email) {
   log.info("Enter email {}", email);
   emailField.clear();
   emailField.sendKeys(email);
   defocus();
   return new EditProfilePage(getDriver());
 }
  @Test
  @DataSet(filename = "dataset/users/usersDataSet.xml", dataSourceBeanId = "dataSource")
  public void testPostEditUserFormFirstNameTooLong() {
    log.debug("testPostEditUserFormFirstNameTooLong");

    openPageAndTestHeader("users/1/edit", "User Form");

    WebElement firstNameInput = driver.findElement(By.id("firstName"));
    Assert.assertNotNull(firstNameInput);
    firstNameInput.clear();
    firstNameInput.sendKeys(StringUtils.repeat("a", 256));

    WebElement submitButton = driver.findElement(By.cssSelector("form#userForm div.buttons input"));
    Assert.assertNotNull(submitButton);

    submitButton.click();

    confirmPageLoadAndTestHeader("User Form");

    WebElement firstNameErrors = driver.findElement(By.id("firstName.errors"));
    Assert.assertNotNull(firstNameErrors);
    Assert.assertEquals(
        "First name must be between 1 and 255 characters.", firstNameErrors.getText());

    List<WebElement> lastNameErrors = driver.findElements(By.id("lastName.errors"));
    Assert.assertNotNull(lastNameErrors);
    Assert.assertTrue(lastNameErrors.isEmpty());
  }
Beispiel #26
0
 public static void main(String[] args) {
   WebDriver driver = new FirefoxDriver();
   driver.get("http://www.google.com");
   WebElement searchBox = driver.findElement(By.name("q"));
   searchBox.sendKeys(Keys.chord(Keys.SHIFT, "packt publishing"));
   searchBox.clear();
 }
 public EditProfilePage enterName(String name) {
   log.info("Enter name {}", name);
   nameField.clear();
   nameField.sendKeys(name);
   defocus();
   return new EditProfilePage(getDriver());
 }
  @Test
  @DataSet(filename = "dataset/users/usersDataSet.xml", dataSourceBeanId = "dataSource")
  public void testPostEditUserFormLastNameEmpty() {
    log.debug("testPostEditUserFormLastNameEmpty");

    openPageAndTestHeader("users/1/edit", "User Form");

    WebElement lastNameInput = driver.findElement(By.id("lastName"));
    Assert.assertNotNull(lastNameInput);
    lastNameInput.clear();

    WebElement submitButton = driver.findElement(By.cssSelector("form#userForm div.buttons input"));
    Assert.assertNotNull(submitButton);

    submitButton.click();

    confirmPageLoadAndTestHeader("User Form");

    WebElement lastNameErrors = driver.findElement(By.id("lastName.errors"));
    Assert.assertNotNull(lastNameErrors);
    Assert.assertEquals("Last name can not be empty.", lastNameErrors.getText());

    List<WebElement> firstNameErrors = driver.findElements(By.id("firstName.errors"));
    Assert.assertNotNull(firstNameErrors);
    Assert.assertTrue(firstNameErrors.isEmpty());
  }
  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();
  }
 protected void clickArticleDeleteConfirmationButton() {
   waitForElementByElement(deleteConfirmationButton);
   waitForElementByElement(deleteCommentReasonField);
   deleteCommentReasonField.clear();
   deleteCommentReasonField.sendKeys("QAReason");
   deleteConfirmationButton.click();
 }