Example usage for org.openqa.selenium WebElement sendKeys

List of usage examples for org.openqa.selenium WebElement sendKeys

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement sendKeys.

Prototype

void sendKeys(CharSequence... keysToSend);

Source Link

Document

Use this method to simulate typing into an element, which may set its value.

Usage

From source file:TestaCadastroProcesso.java

@Test(groups = "login")
public void testaLoginSiapcon() throws Exception {

    driver.navigate().to("http://52.1.49.37/SIAPCON_SPRINT11/");

    DefaultThrowTreatment def = new DefaultThrowTreatment();

    // verifica se os elementos existem
    def.verifyElementPresenceById(driver, "RichWidgets_wt33:wtMainContent:wtUserNameInput");
    def.verifyElementPresenceById(driver, "RichWidgets_wt33:wtMainContent:wtPasswordInput");
    def.verifyElementPresenceById(driver, "RichWidgets_wt33:wtMainContent:wtLoginButton");

    // caso exista escreve
    WebElement inputUser = driver.findElement(By.id("RichWidgets_wt33:wtMainContent:wtUserNameInput"));
    WebElement inputPasswd = driver.findElement(By.id("RichWidgets_wt33:wtMainContent:wtPasswordInput"));
    WebElement buttonLogin = driver.findElement(By.id("RichWidgets_wt33:wtMainContent:wtLoginButton"));

    // escreve as informaes=
    inputUser.sendKeys("claudiana.coelho");
    inputPasswd.sendKeys("123456");

    // clica no boto
    buttonLogin.click();/*from   w w  w  .j  a v a  2 s .c  o  m*/
}

From source file:TestaCadastroProcesso.java

@Test(dependsOnGroups = "login", groups = "required")
public void testaMsgNumero() throws Exception {

    driver.navigate()/*from  ww  w .j  a  v  a  2 s.c o m*/
            .to("http://52.1.49.37/SIAPCON_SPRINT11/ListarProcessos.jsf?(Not.Licensed.For.Production)=");

    driver.navigate().to(
            "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)=");

    // gera um tempo de espera para a pgina carregar e o elemento ser renderizado
    driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);

    try {

        // insere um numero de processo valido
        WebElement numero = driver
                .findElement(By.id("RichWidgets_wt95:wtMainContent:wtnumeroProcessoAtualWidget"));
        numero.sendKeys("000");

        // clica no boto submit
        WebElement submit = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wt38"));
        submit.click();

        // Espera at que o elemento que contm a msg de erro esteja vsivel
        WebDriverWait wait = new WebDriverWait(driver, 30);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("Feedback_Message_Error")));

        // testa se a msg de obrigatoriedade est sendo exibida
        if (!driver.findElement(By.className("Feedback_Message_Error")).isDisplayed()) {
            Assert.fail("No est exibindo msg");
        }

    } catch (Exception e) {
        throw (e);
    }

    driver.navigate().to(
            "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)=");

    // insere um numero de processo valido
    WebElement numero = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wtnumeroProcessoAtualWidget"));
    numero.sendKeys("00000.000000/00");

    try {

        // clica no boto submit
        WebElement submit = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wt38"));
        submit.click();

        // espera at que o elemento que contm a msg de erro esteja visvel
        WebDriverWait wait = new WebDriverWait(driver, 30);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("Feedback_Message_Error")));

        if (!driver.findElement(By.className("Feedback_Message_Error")).isDisplayed()) {
            Assert.fail("No est exibindo msg");
        }

    } catch (Exception e) {
        throw (e);
    }
}

From source file:TestaCadastroProcesso.java

@Test(dependsOnGroups = "required", groups = "salva")
public void testaInsercaoProcesso() {

    driver.navigate().to(/*ww w  . j a  v a  2s. co  m*/
            "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)=");

    driver.navigate().to(
            "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)=");

    try {

        // insere um numero de processo valido
        WebElement numero = driver
                .findElement(By.id("RichWidgets_wt95:wtMainContent:wtnumeroProcessoAtualWidget"));
        numero.sendKeys(proc);

        // insere um tipo de processo valido
        WebElement tipo = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wttipoProcessoWidget"));
        tipo.sendKeys("a");

        // clica no boto submit
        WebElement submit = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wt38"));
        submit.click();

        // espera at que o boto de encerrar cadastro esteja visvel
        WebDriverWait wait = new WebDriverWait(driver, 60);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("corbranca")));

        if (!driver.findElement(By.className("corbranca")).isDisplayed()) {
            Assert.fail("No exibiu o boto encerrar cadastro");
        }
    } catch (Exception e) {
        throw (e);
    }
}

From source file:TestaCadastroProcesso.java

@Test(dependsOnGroups = "salva", groups = "salvou")
public void testaSeInseriuProcesso() throws Exception {

    driver.navigate()//from  w w w.j a  v a2s.  c  om
            .to("http://52.1.49.37/SIAPCON_SPRINT11/ListarProcessos.jsf?(Not.Licensed.For.Production)=");

    try {

        // insere orgao do processo na busca
        WebElement orgao = driver
                .findElement(By.id("RichWidgets_wt88:wtMainContent:wtnumeroProcessoOrgaoWidget"));
        orgao.sendKeys(proc.substring(0, 5));

        // insere numero do processo na busca
        WebElement numero = driver
                .findElement(By.id("RichWidgets_wt88:wtMainContent:wtnumeroProcessoNumeroWidget"));
        numero.sendKeys(proc.substring(5, 11));

        // insere ano do processo na busca
        WebElement ano = driver.findElement(By.id("RichWidgets_wt88:wtMainContent:wtnumeroProcessoAnoWidget"));
        ano.sendKeys(proc.substring(11, 13));

        // acha o input do submit e clica para fazer a pesquisa
        WebElement submit3 = driver.findElement(By.xpath("//input[@type='submit']"));
        submit3.click();

        // para esperar a resposta do Ajax impede o Selenium de prosseguir
        Thread.sleep(60000);

        WebElement table = driver.findElement(By.id("RichWidgets_wt88:wtMainContent:wtProcessoTableAjaxRfrsh"));

        WebElement a = driver.findElement(By.id("RichWidgets_wt88:wtMainContent:wtProcessoTable:0:wt7"));

        String processo = proc.substring(0, 5) + "." + proc.substring(5, 11) + "/" + proc.substring(11, 13);

        if (!a.getText().toString().contains(processo)) {
            Assert.fail("No cadastrou!");
        }

    } catch (Exception e) {
        throw (e);
    }
}

From source file:TestWriteanArticle.java

@org.junit.Test
public void positive() throws InterruptedException {
    System.setProperty("webdriver.gecko.driver", "C://Users/Mari/Downloads/geckodriver.exe");
    WebDriver webDriver = new FirefoxDriver();
    String page = "http://www.wikihow.com/Special:CreatePage";
    webDriver.get(page);/*from   w  w w .j a v  a 2  s .  c  o m*/
    WebElement title = webDriver.findElement(By.id("cp_title_input"));
    title.sendKeys("how to use selenium");
    webDriver.findElement(By.id("cp_title_btn")).click();
    Thread.sleep(10);

    WebDriverWait wait = new WebDriverWait(webDriver, 50);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cpr_title_hdr")));
    assertTrue(webDriver.getPageSource().contains("Are any of these topics the same as yours?"));

    webDriver.close();
}

From source file:TestWriteanArticle.java

@org.junit.Test
public void negative() throws InterruptedException {
    System.setProperty("webdriver.gecko.driver", "C://Users/Mari/Downloads/geckodriver.exe");
    WebDriver webDriver = new FirefoxDriver();
    String page = "http://www.wikihow.com/Special:CreatePage";
    webDriver.get(page);/*w  w  w .j av  a2  s.  co m*/
    WebElement title = webDriver.findElement(By.id("cp_title_input"));
    title.sendKeys("how to use wikiHow");
    webDriver.findElement(By.id("cp_title_btn")).click();
    Thread.sleep(10);

    WebDriverWait wait = new WebDriverWait(webDriver, 50);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cpr_title_hdr")));
    assertTrue(webDriver.getPageSource().contains("That article already exists!"));

    webDriver.close();
}

From source file:AndroidRemoteDriverTest.java

/**
 * @param args the command line arguments
 *///from w w w . j a  v a2 s  . com
public static void main(String[] args) {

    AndroidRemoteWebDriver driver = new AndroidRemoteWebDriver("ws://localhost:9222/devtools/page/4");
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.get("http://www.google.com");
    Utils.sleep(2000);
    WebElement elm = driver.findElement(By.name("q"));
    Utils.sleep(2000);
    elm.sendKeys(" // \\ ' * [@id=\"rg_s\"]/div[1]/a ");
    elm.submit();
    //Utils.sleep(2000);
    elm = driver.findElement(By.partialLinkText("Images"));
    elm.click();
    Utils.sleep(2000);
    elm = driver.findElement(By.xpath("//*[@id=\"rg_s\"]/div[1]/a"));
    elm.click();
    Utils.sleep(2000);
    System.out.println("Page source :/n" + driver.getPageSource());

}

From source file:SmokeTester_UnitTest.java

public void executeSmokeTest() throws Exception {
    // Create a new instance of the Firefox driver
    // Notice that the remainder of the code relies on the interface, 
    // not the implementation.

    System.setProperty("webdriver.chrome.driver", "C:\\Nino\\ChromeWebDriver\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();

    TestCaseReader tcreader = new TestCaseReader();
    List<TestScriptTemplate> tcl = tcreader.readExcel();

    List<TestScriptTemplate> validatedTestScript = new ArrayList();

    String log_execution = "";
    Iterator<TestScriptTemplate> i = tcl.iterator();
    while (i.hasNext()) {
        TestScriptTemplate testscript = i.next();
        //collect the results
        TestScriptTemplate testexecution = new TestScriptTemplate();

        testexecution.setAppCode(testscript.getAppCode());
        log_execution = log_execution + "\nStart smoke testing for application code: "
                + testexecution.getAppCode();

        //access the URL
        driver.get(testscript.getAppURL());

        //login if not yet
        if (driver.getCurrentUrl().contains("identity.safeway.com")) {
            //key in userid and password
            WebElement weusername = driver.findElement(By.id("username"));
            //System.out.println("tag:" + weusername.getTagName());
            weusername.sendKeys(testscript.getAppUserID());

            WebElement wepassword = driver.findElement(By.id("password"));
            //System.out.println("tag:" + wepassword.getTagName());
            wepassword.sendKeys(testscript.getAppPassword());

            WebElement weloginform = driver.findElement(By.name("loginData"));
            //System.out.println("tag:" + weloginform.getTagName());
            weloginform.submit();/* w ww  . j  a  va  2s.c  om*/
            log_execution = log_execution + " Login Successful";
        }

        //recoding URL; required so no need to check for nullity
        testexecution.setAppURL(driver.getCurrentUrl());
        log_execution = log_execution + " Current URL: " + driver.getCurrentUrl();
        //recoding title; required so no need to check for nullity
        testexecution.setHomePageTitle(driver.getTitle());
        log_execution = log_execution + " Page Title: " + driver.getTitle();

        if (isElementExist(testscript.getHomePageElementType(), testscript.getHomePageElement(), driver)) {
            System.out.println("Element match!" + testscript.getHomePageElement());
            log_execution = log_execution + " Home Page Element validation...";
            testexecution.setHomePageElement(testscript.getHomePageElement());
        } else {
            testexecution.setHomePageElement("not found");
        }

        //next page validation
        if (!testscript.getLevel1URL().isEmpty() || !testscript.getLevel1URL().equals("")) {
            //go to next level page
            driver.get(testscript.getLevel1URL());
            log_execution = log_execution + " Next Page validation URL: " + testscript.getLevel1URL();

            testexecution.setLevel1URL(driver.getCurrentUrl());
            System.out.println("execution log: current level 1 URL on set" + testexecution.getLevel1URL());

            if (!testscript.getLevel1PageTitle().isEmpty() || !testscript.getLevel1PageTitle().equals("")) {
                testexecution.setLevel1PageTitle(driver.getTitle());
                log_execution = log_execution + " Next Page title validation: " + driver.getTitle();
            }

            if (isElementExist(testscript.getLevel1ElementType(), testscript.getLevel1Element(), driver)) {
                testexecution.setLevel1Element(testscript.getLevel1Element());
                log_execution = log_execution + " Next Page element validation: "
                        + testscript.getLevel1Element();
            } else {
                testexecution.setLevel1Element("not found");
            }

        }
        testexecution.setLogs(log_execution);
        SmokeTestValidator_UnitTest testvalidator = new SmokeTestValidator_UnitTest(testscript);
        TestScriptTemplate testingresult = testvalidator.getTestResult(testexecution);
        validatedTestScript.add(testingresult);

    }

    tcreader.writetoExcel(validatedTestScript);
    //Close the browser
    driver.quit();
    //return log_execution;
}

From source file:AddReport.java

public static void main(String[] args) throws Exception {

    ChromeDriver driver = new ChromeDriver();

    driver.get("http://testwave.qabidder.net/#/page/login");
    driver.manage().window().maximize();

    driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

    //      Login page

    WebElement emailTextBox = driver.findElement(By.id("exampleInputEmail1"));
    emailTextBox.sendKeys("qabootcamp@mailinator.com");

    WebElement passwdTextBox = driver.findElement(By.id("exampleInputPassword1"));
    passwdTextBox.sendKeys("123456");

    Thread.sleep(5000);//from www .j  a va  2  s  .  c  o m

    WebElement loginButton = driver.findElement(By.tagName("button"));
    loginButton.click();

    Thread.sleep(2000);

    //      Goto Add Report      

    WebElement reports = driver.findElement(By.linkText("Add Report"));
    reports.click();

    //      Select Department

    List<WebElement> radioButtonLabels = driver
            .findElements(By.xpath("//fieldset/*[@class='ng-scope']//label"));
    for (int i = 0; i < radioButtonLabels.size(); i++) {
        WebElement radioButtomLabel = radioButtonLabels.get(i);
        String text = radioButtomLabel.getText();
        if (text.equals("Dep1")) {
            WebElement radioButton = radioButtomLabel.findElement(By.xpath("span"));
            radioButton.click();
        }
    }

    WebElement nextButton = driver.findElement(By.cssSelector(".next>a"));
    nextButton.click();

    //      Subject Information Section      

    WebElement caseId = driver
            .findElement(By.cssSelector(".form-control.ng-pristine.ng-untouched.ng-valid.ng-empty"));
    caseId.sendKeys("123");

    WebElement suspectDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.suspectType']"));
    suspectDropDown.findElement(By.xpath("option[text()='Suspect']")).click();

    WebElement lastName = driver.findElement(By.xpath("//input[@ng-model='wizard.report.lastName']"));
    lastName.sendKeys("LastName");

    WebElement firstName = driver.findElement(By.xpath("//input[@ng-model='wizard.report.firstName']"));
    firstName.sendKeys("FirstName");

    WebElement middleName = driver.findElement(By.xpath("//input[@ng-model='wizard.report.middleName']"));
    middleName.sendKeys("MiddleName");

    WebElement nickName = driver.findElement(By.xpath("//input[@ng-model='wizard.report.nickname']"));
    nickName.sendKeys("NickName");

    WebElement dob = driver.findElement(By.xpath("//input[@ng-model='wizard.report.dob']"));
    dob.sendKeys("01/01/2001");

    WebElement ageNumber = driver.findElement(By.xpath("//input[@ng-model='wizard.report.age']"));
    ageNumber.sendKeys("42");

    WebElement sexDropDown = driver.findElement(By.xpath("//select[@ng-model='wizard.report.sex']"));
    sexDropDown.findElement(By.xpath("option[text()='M']")).click();

    WebElement raceDropDown = driver.findElement(By.xpath("//select[@ng-model='wizard.report.race']"));
    raceDropDown.findElement(By.xpath("option[text()='Cambodian']")).click();

    WebElement height = driver.findElement(By.xpath("//input[@ng-model='wizard.report.height']"));
    height.sendKeys("6.00");

    WebElement weight = driver.findElement(By.xpath("//input[@ng-model='wizard.report.weight']"));
    weight.sendKeys("226.0");

    WebElement buildDropDown = driver.findElement(By.xpath("//select[@ng-model='wizard.report.build']"));
    buildDropDown.findElement(By.xpath("option[text()='Obese']")).click();

    WebElement hairColorDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.hairColor']"));
    hairColorDropDown.findElement(By.xpath("option[text()='Black']")).click();

    WebElement hairLengthDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.hairLength']"));
    hairLengthDropDown.findElement(By.xpath("option[text()='Short']")).click();

    WebElement hairStyleDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.hairStyle']"));
    hairStyleDropDown.findElement(By.xpath("option[text()='Afro']")).click();

    WebElement eyeColorDropDown = driver.findElement(By.xpath("//select[@ng-model='wizard.report.eyeColor']"));
    eyeColorDropDown.findElement(By.xpath("option[text()='Brown']")).click();

    WebElement complexionDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.complexion']"));
    complexionDropDown.findElement(By.xpath("option[text()='Dark']")).click();

    WebElement teethDropDown = driver.findElement(By.xpath("//select[@ng-model='wizard.report.teeth']"));
    teethDropDown.findElement(By.xpath("option[text()='Gold']")).click();

    WebElement handPreferenceDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.handPreference']"));
    handPreferenceDropDown.findElement(By.xpath("option[text()='Left']")).click();

    WebElement primaryLanguage = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.primaryLanguage']"));
    primaryLanguage.sendKeys("English");

    WebElement streetAddress = driver.findElement(By.xpath("//input[@ng-model='wizard.report.streetAddress']"));
    streetAddress.sendKeys("1234 Any St.");

    WebElement countryDropDown = driver.findElement(By.xpath("//select[@ng-model='wizard.report.country']"));
    countryDropDown.findElement(By.xpath("option[text()='Cambodia']")).click();

    WebElement city = driver.findElement(By.xpath("//input[@ng-model='wizard.report.city']"));
    city.sendKeys("Any City");

    WebElement state = driver.findElement(By.xpath("//input[@ng-model='wizard.report.state']"));
    state.sendKeys("Phnom Penh");

    WebElement zip = driver.findElement(By.xpath("//input[@ng-model='wizard.report.zip']"));
    zip.sendKeys("12345");

    WebElement contactTelephone = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.contactTelephone']"));
    contactTelephone.sendKeys("1234567890");

    WebElement contactEmail = driver.findElement(By.xpath("//input[@ng-model='wizard.report.contactEmail']"));
    contactEmail.sendKeys("name@mail.com");

    List<WebElement> roadRadioButtonLabels = driver.findElements(By.xpath("//fieldset/*[@class='row']//label"));

    for (int i = 0; i < roadRadioButtonLabels.size(); i++) {
        WebElement roadRadioButtomLabel = roadRadioButtonLabels.get(i);
        String text = roadRadioButtomLabel.getText();
        if (text.equals("Passenger")) {
            WebElement roadRadioButton = roadRadioButtomLabel.findElement(By.xpath("span"));
            roadRadioButton.click();
        }
    }

    WebElement identifierTab = driver.findElement(By.xpath("//a[@ng-click='wizard.go(3)']"));
    identifierTab.click();

    //      Identifier Section

    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.tattoos']")).click();
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@placeholder='Tattoos']")).sendKeys("Ugly Tattoos");
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.scars']")).click();
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@placeholder='Scars']")).sendKeys("Ugly Scars");
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.needleMarks']")).click();
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@placeholder='Needle marks']")).sendKeys("Ugly Marks");
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.tracks']")).click();
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@placeholder='Tracks']")).sendKeys("Ugly Tracks");
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.glasses']")).click();
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@placeholder='Glasses']")).sendKeys("Ugly Glasses");
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.mustache']")).click();
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@placeholder='Mustache']")).sendKeys("Ugly Mustache");
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.beard']")).click();
    Thread.sleep(2000);

    driver.findElement(By.xpath("//input[@placeholder='Beard']")).sendKeys("Ugly Beard");
    Thread.sleep(2000);

    WebElement idInfoTab = driver.findElement(By.xpath("//div[@title='ID Information']"));
    idInfoTab.click();
    Thread.sleep(2000);

    //      ID Information Section

    WebElement socialSecurity = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.socialSecurity']"));
    socialSecurity.sendKeys("123-12-1234");

    WebElement driverLicense = driver.findElement(By.xpath("//input[@ng-model='wizard.report.driverLicense']"));
    driverLicense.sendKeys("B2983777");

    WebElement dlStateDropDown = driver.findElement(By.xpath("//select[@ng-model='wizard.report.dlState']"));
    dlStateDropDown.findElement(By.xpath("option[text()='California']")).click();

    WebElement otherId = driver.findElement(By.xpath("//input[@ng-model='wizard.report.otherId']"));
    otherId.sendKeys("Other ID");

    WebElement otherIdCountryDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.otherIdCountry']"));
    otherIdCountryDropDown.findElement(By.xpath("option[text()='Cambodia']")).click();

    WebElement otherIdState = driver.findElement(By.xpath("//input[@ng-model='wizard.report.otherIdState']"));
    otherIdState.sendKeys("Phnom Penh");

    WebElement otherIdType = driver.findElement(By.xpath("//input[@ng-model='wizard.report.otherIdType']"));
    otherIdType.sendKeys("Ugly ID Card");

    //      School Information

    WebElement schoolName = driver.findElement(By.xpath("//input[@ng-model='wizard.report.schoolName']"));
    schoolName.sendKeys("The Ugly High School");

    WebElement schoolAddress = driver.findElement(By.xpath("//input[@ng-model='wizard.report.schoolAddress']"));
    schoolAddress.sendKeys("1234 Ugly Way");

    WebElement schoolCity = driver.findElement(By.xpath("//input[@ng-model='wizard.report.schoolCity']"));
    schoolCity.sendKeys("Uglyville");

    WebElement schoolStateDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.schoolState']"));
    schoolStateDropDown.findElement(By.xpath("option[text()='Utah']")).click();

    WebElement schoolZip = driver.findElement(By.xpath("//input[@ng-model='wizard.report.schoolZip']"));
    schoolZip.sendKeys("12345");

    WebElement schoolTelephone = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.schoolTelephone']"));
    schoolTelephone.sendKeys("1231231234");

    //      Parent Information

    WebElement parentName = driver.findElement(By.xpath("//input[@ng-model='wizard.report.parentName']"));
    parentName.sendKeys("The Jetsons");

    WebElement parentAddress = driver.findElement(By.xpath("//input[@ng-model='wizard.report.parentAddress']"));
    parentAddress.sendKeys("1234 Uglier Way");

    WebElement parentCity = driver.findElement(By.xpath("//input[@ng-model='wizard.report.parentCity']"));
    parentCity.sendKeys("Uglyville");

    WebElement parentStateDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.parentState']"));
    parentStateDropDown.findElement(By.xpath("option[text()='Utah']")).click();

    WebElement parentZip = driver.findElement(By.xpath("//input[@ng-model='wizard.report.parentZip']"));
    parentZip.sendKeys("12345");

    WebElement parentTelephone = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.parentTelephone']"));
    parentTelephone.sendKeys("1231231234");

    //      Employer Information

    WebElement occupation = driver.findElement(By.xpath("//input[@ng-model='wizard.report.occupation']"));
    occupation.sendKeys("The Ugly Mascot");

    WebElement employerName = driver.findElement(By.xpath("//input[@ng-model='wizard.report.employerName']"));
    employerName.sendKeys("The Ugly Ducklings");

    WebElement employerAddress = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.employerAddress']"));
    employerAddress.sendKeys("1234 Ugliest Way");

    WebElement employerCity = driver.findElement(By.xpath("//input[@ng-model='wizard.report.employerCity']"));
    employerCity.sendKeys("Uglyville");

    WebElement employerStateDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.employerState']"));
    employerStateDropDown.findElement(By.xpath("option[text()='Utah']")).click();

    WebElement employerZip = driver.findElement(By.xpath("//input[@ng-model='wizard.report.employerZip']"));
    employerZip.sendKeys("123-12-1234");

    WebElement employerTelephone = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.employerTelephone']"));
    employerTelephone.sendKeys("1231231234");

    Thread.sleep(2000);

    WebElement gangMemberTab = driver.findElement(By.xpath("//a[@ng-click='wizard.go(5)']"));
    gangMemberTab.click();

    //      Distribution Seciton

    Thread.sleep(2000);
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.gangUnit']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.sexCrimes']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.robbery']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.narco']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.viceIntel']")).click();

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.other']")).click();
    Thread.sleep(2000);
    driver.findElement(By.xpath("//input[@placeholder='Other Distribution']")).sendKeys("Ugly Mustache");
    Thread.sleep(2000);

    WebElement reasonForStop = driver.findElement(By.xpath("//input[@ng-model='wizard.report.reasonForStop']"));
    reasonForStop.sendKeys("Looking Too Ugly");

    WebElement locationOfStop = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.locationOfStop']"));
    locationOfStop.sendKeys("In Front Of An Ugly Building");

    WebElement dispositionOfStop = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.dispositionOfStop']"));
    dispositionOfStop.sendKeys("I Dont Know!!!");

    WebElement gangName = driver.findElement(By.xpath("//input[@ng-model='wizard.report.gangName']"));
    gangName.sendKeys("BULB");

    WebElement howLong = driver.findElement(By.xpath("//input[@ng-model='wizard.report.howLong']"));
    howLong.sendKeys("Too Long");

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.selfAdmission']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.frequentingGangArea']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.displayingGangSigns']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.byReliableInformant']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.gangTattoos']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.gangClothing']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.affiliatingWithGangMembers']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.participatingInGangCrime']")).click();
    driver.findElement(By.xpath("//input[@ng-model='wizard.report.gangRegistrant']")).click();

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.onParole']")).click();
    Thread.sleep(2000);
    driver.findElement(By.xpath("//input[@placeholder='Parole Officer']")).sendKeys("Officer Bob");
    driver.findElement(By.xpath("//input[@placeholder='Parole Officer Phone']")).sendKeys("1231231234");

    driver.findElement(By.xpath("//input[@ng-model='wizard.report.onProbation']")).click();
    Thread.sleep(2000);
    driver.findElement(By.xpath("//input[@placeholder='Probation Officer']")).sendKeys("Officer Jim");
    driver.findElement(By.xpath("//input[@placeholder='Probation Officer Phone']")).sendKeys("1231231234");

    WebElement otherInformation = driver
            .findElement(By.xpath("//textarea[@ng-model='wizard.report.otherInformation']"));
    otherInformation.sendKeys("Other Information");

    WebElement officerId = driver.findElement(By.xpath("//input[@ng-model='wizard.report.officerId']"));
    officerId.sendKeys("112233");

    WebElement beat = driver.findElement(By.xpath("//input[@ng-model='wizard.report.beat']"));
    beat.sendKeys("Im Beat.");

    Thread.sleep(2000);

    WebElement vehicleTab = driver.findElement(By.xpath("//a[@ng-click='wizard.go(6)']"));
    vehicleTab.click();

    //      Vehicle Section

    WebElement vehicleLicense = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.vehicleLicense']"));
    vehicleLicense.sendKeys("1ABC123");

    WebElement vehicleMake = driver.findElement(By.xpath("//input[@ng-model='wizard.report.vehicleMake']"));
    vehicleMake.sendKeys("UZA");

    WebElement vehicleModel = driver.findElement(By.xpath("//input[@ng-model='wizard.report.vehicleModel']"));
    vehicleModel.sendKeys("Urraco");

    WebElement vehicleBodystyle = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.vehicleBodystyle']"));
    vehicleBodystyle.sendKeys("Unique");

    WebElement vehicleYear = driver.findElement(By.xpath("//input[@ng-model='wizard.report.vehicleYear']"));
    vehicleYear.sendKeys("2000");

    WebElement vehicleColors = driver.findElement(By.xpath("//input[@ng-model='wizard.report.vehicleColors']"));
    vehicleColors.sendKeys("Ube");

    WebElement vehicleStateDropDown = driver
            .findElement(By.xpath("//select[@ng-model='wizard.report.vehicleState']"));
    vehicleStateDropDown.findElement(By.xpath("option[text()='Utah']")).click();

    WebElement vehicleOddities = driver
            .findElement(By.xpath("//input[@ng-model='wizard.report.vehicleOddities']"));
    vehicleOddities.sendKeys("Ultra Wide");

    Thread.sleep(2000);

    //      Photo Upload Section

    WebElement photoTab = driver.findElement(By.xpath("//a[@ng-click='wizard.go(7)']"));
    photoTab.click();

    Thread.sleep(2000);

    WebElement previewTab = driver.findElement(By.xpath("//a[@ng-click='wizard.go(8)']"));
    previewTab.click();

    //      Preview Section      

    Thread.sleep(2000);

    WebElement publishButton = driver.findElement(By.xpath("//button[@ng-click='wizard.commitReport()']"));
    publishButton.click();

    System.out.println("complete");

    driver.close();
    driver.quit();

}

From source file:TestWithSelenium.java

@Test
public void uTest2002Filter() {
    //searching for filter & sending key
    WebElement filter = (new WebDriverWait(driver, MAX))
            .until((ExpectedCondition<WebElement>) (WebDriver d) -> {
                return d.findElement(By.id("filter"));
            });//from   ww  w  .ja  v a  2 s.c  o m
    filter.sendKeys("2002");

    //searching for tbody
    WebElement table = (new WebDriverWait(driver, MAX)).until((ExpectedCondition<WebElement>) (WebDriver d) -> {
        return d.findElement(By.tagName("tbody"));
    });

    //checking whether number of rows is 2
    Assert.assertThat(table.findElements(By.tagName("tr")).size(), is(2));

}