Example usage for org.openqa.selenium Keys ENTER

List of usage examples for org.openqa.selenium Keys ENTER

Introduction

In this page you can find the example usage for org.openqa.selenium Keys ENTER.

Prototype

Keys ENTER

To view the source code for org.openqa.selenium Keys ENTER.

Click Source Link

Usage

From source file:com.mx.santander.lh.obpyme.Operacion.OperacionesMarketingSantander.java

public void OperacionesCampaniaMArketing(WebDriver driver) throws InterruptedException, IOException {

    //OPERACIONES DE MANEJO DE BROWSER
    driver.manage().window().maximize();
    driver.get("http://www.google.com");

    //VALIDACION DE ELEMENTOS PARA INICIO DE PRUEBA
    Thread.sleep(3000);//from   w  ww . j a  v  a 2 s  .c  o  m
    if (validacionesMArketing.ValidaElementosMarketingSantander(driver)) {
        System.out.println("----- INICIA TEST AUTOMATIZADO -----");
        System.out.println("------------------------------------");
        System.out.println("Caso de prueba: " + datos.RecuperarDatosExcel().getCasoPrueba());
        System.out.println("");
        //REALIZA LA BUSQUEDA DE LA EMPRESA A LA QUE SE LE VA A REALIZAR EL MARKETING
        elementos.ElementoTextInputBusqueda(driver).sendKeys(datos.RecuperarDatosExcel().getEmpresaMarketing());
        elementos.ElementoTextInputBusqueda(driver).sendKeys(Keys.ENTER);
        Thread.sleep(3000);

        System.out.println("----- DATOS DE PRUEBA -----");
        System.out.println("---------------------------");
        System.out.println("EMPRESA: " + datos.RecuperarDatosExcel().getEmpresaMarketing());
        System.out.println("ENLACE TOP 1: " + datos.RecuperarDatosExcel().getPosicionamientoMarketingTopURL());
        System.out.println("TOP NUMBER: " + datos.RecuperarDatosExcel().getTopNumber());
        System.out.println("");

        //VALIDA SI SE ENCONTRARON VALORES EN LA BUSQUEDA.
        if (validacionesMArketing.ValidaListaElementosResultados(driver)) {
            List<WebElement> listaElementos = elementos.ListaURLBusqueda(driver);
            //RECORREMOS LA LISTA DE ELEMENTOS RECUPERADOS PARA IDENTIFICAR SI LA EMPRESA DE MARKETING SE ENCUENTRA EN LA POSICION INDICADA
            System.out.println("----- RESULTADO DEL TEST AUTOMATIZADO -----");
            System.out.println("-------------------------------------------");

            int contador = 0;
            for (WebElement elemento : listaElementos) {
                contador++;
                //LA EMPRESA SE ENCUENTRA EN EL TOP TEN
                if (elemento.getText().equals(datos.RecuperarDatosExcel().getPosicionamientoMarketingTopURL())
                        && contador == datos.RecuperarDatosExcel().getTopNumber()) {
                    System.out.println("LA EMPRESA SE ENCUENTRA EN EL TOP TEN DE BUSQUEDA EN GOOGLE");
                    driver.close();
                    break;
                }
                //LA EMPRESA NO SE ENCUENTRA EN EL TOP TEN.
                if (contador == listaElementos.size()) {
                    System.out
                            .println("LA EMPRESA NO SE ENCUENTRA EN EL TOP TEN INICIAR CAMPAA DE MARKETING");
                    driver.close();
                }
            }
        }
    } else {
        //NO SE ENCONTRARON LOS ELEMENTOS NECESARIOS PARA COMENZAR CON LA PRUEBA
        System.out.println("LA BUSQUEDA EN GOOGLE NO SE ENCUENTRA DISPONIBLE POR EL MOMENTO");
    }

}

From source file:com.mycompany.newseleniumtest.TestScript.java

public boolean Apply_new() throws InterruptedException, AWTException {
    boolean output = false;
    this.startDriver("firefox");
    WebDriverWait wait = new WebDriverWait(this.driver, 10);

    //Open the page
    if (this.testLocation.equals("local")) {
        this.driver.get("localhost:80/uang-teman/");
    } else //  this.driver.get("https://dev.uangteman.com/___organic"); 
    {/*  www. j  av  a2  s .c o m*/
        if (this.isCampaign) {
            this.driver.get("https://" + this.testLocation + ".uangteman.com/" + campaign);
        } else {
            //                this.driver.get("https://hotfix.uangteman.com");
            this.driver.get("https://" + this.testLocation + ".uangteman.com/"); //https://dev.uangteman.com/a/NHeHv
        }
    }

    WebElement main;

    //IntroPage

    //        main=driver.findElement(By.cssSelector("div[id='pinjaman-side'"));
    //        Point point = main.getLocation();
    //        int xcord = point.getX();
    //        System.out.println("Element's Position from left side Is "+xcord +" pixels.");
    //        int ycord = point.getY();
    //        System.out.println("Element's Position from top side Is "+ycord +" pixels.");
    //        main = this.driver.findElement(By.cssSelector("div[id='pinjaman-side']"));
    //        main = this.driver.findElement(By.cssSelector("div[id='ajukan-pinjaman-box']"));

    if (this.testLocation.equals("hotfix")) {

        main = this.driver.findElement(By.cssSelector("div[id='home']"));
        main = this.driver.findElement(By.cssSelector("div[id='ajukan-pinjaman-box']"));
        main.findElement(By.cssSelector("a[href='https://hotfix.uangteman.com/loan-calculator")).click();

    } else {
        if (this.testLocation.equals("dev")) {
            Thread.sleep(5000);

            main = this.driver.findElement(By.cssSelector("div[id='home']"));
            main = this.driver.findElement(By.cssSelector("div[id='ajukan-pinjaman-box']"));
            main.findElement(By.cssSelector("a[href='https://dev.uangteman.com/loan-calculator")).click();
        } else {
            Thread.sleep(5000);

            main = this.driver.findElement(By.cssSelector("div[id='home']"));
            main = this.driver.findElement(By.cssSelector("div[id='ajukan-pinjaman-box']"));
            main.findElement(By.cssSelector("a[href='https://staging.uangteman.com/loan-calculator")).click();
        }
    }

    /* 
    main = this.driver.findElement(By.cssSelector("div[id='pinjaman-side']"));
            
    // case when
    main.findElement(By.cssSelector("a[href='https://hotfix.uangteman.com/loan-calculator")).click();
    **/

    //calculator
    //main.findElement(By.id("ap_email_address")).clear();
    main = driver.findElement(By.cssSelector("div[class='container']"));
    main = driver.findElement(By.cssSelector("div[class='row']"));
    main = driver.findElement(By.cssSelector("div[class='col-xs-12']"));
    main = driver.findElement(By.cssSelector("form[id='form-calculator']"));
    main = driver.findElement(By.cssSelector("div[class='ut-form-container']"));
    main = driver.findElement(By.cssSelector("div[class='ut-form-box1']"));
    /*
    //start slide
    WebElement dragElementFrom = driver.findElement(By.xpath("//span[contains(@class, 'ui-slider-handle')]")); 
            
    new Actions(driver).dragAndDropBy(dragElementFrom, 100, 0).build().perform();
    Thread.sleep(5000);
    //end slide
    new Actions(driver).clickAndHold(dragElementFrom).moveByOffset(100,0).release().perform();
    **/

    if (this.isPromo) {
        main.findElement(By.id("promo_code")).sendKeys(this.promo_code, Keys.ENTER);
        Thread.sleep(4000);
    }

    Thread.sleep(4000);
    main.findElement(By.cssSelector("a[class='btn btn-medium monserat btn-pinjam-sekarang']")).click();

    //term and condition
    main = driver.findElement(By.cssSelector("div[class='container']"));
    main = driver.findElement(By.cssSelector("form[id='agreement-form']"));
    main = driver.findElement(By.cssSelector("div[class='col-md-12 ut-form-container']"));
    main.findElement(By.cssSelector("button[id='checklist-button']")).click();
    //        main.findElement(By.id("ajukan-pinjaman-final")).submit();
    Thread.sleep(1000);

    //detail kontak
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main.findElement(By.id("ap_email_address")).clear();
    main.findElement(By.id("ap_email_address")).sendKeys(this.email);
    main.findElement(By.id("ap_mobile_no")).clear();
    main.findElement(By.id("ap_mobile_no")).sendKeys(this.mobile_no);
    main.findElement(By.id("ap_personal_id_no")).clear();
    main.findElement(By.id("ap_personal_id_no")).sendKeys(this.no_ktp);
    //main.findElement(By.id("ap_personal_id_no")).sendKeys(SupportController.createRandom(17));
    Thread.sleep(1000);

    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = driver.findElement(By.cssSelector("form[id='step1']"));
    main = driver.findElement(By.cssSelector("div[class='ut-form-box2 clearfix']"));
    main.findElement(By.cssSelector("button[class='btn-next']")).click();
    Thread.sleep(11000);

    //form purpose loan
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = driver.findElement(By.cssSelector("form[id='step2']"));
    main = driver.findElement(By.cssSelector("div[class='ut-form-box2 clearfix']"));
    main = driver.findElement(By.cssSelector("div[class='ut-form-content']"));
    main = driver.findElement(By.cssSelector("div[class='selection-box-first']"));
    main.findElement(By.cssSelector("div[class='selection-radio']")).click();
    Thread.sleep(1000);

    driver.findElement(By.xpath("//*[@id='step2']/div/div[2]/button[2]")).click();

    //form know ut
    driver.findElement(By.xpath("//*[@id='step3']/div/div[1]/div[1]/div[2]/label/span")).click();

    driver.findElement(By.xpath("//*[@id='step3']/div/div[2]/button[2]")).click();
    Thread.sleep(1000);

    //more detail kontak
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step4']"));
    main.findElement(By.id("ap_full_name")).clear();
    main.findElement(By.id("ap_full_name")).sendKeys(this.nama);
    main.findElement(By.id("ap_gender")).sendKeys("l", Keys.ENTER);
    main.findElement(By.id("ap_pob")).clear();
    main.findElement(By.id("ap_pob")).sendKeys("Jakarta");
    Thread.sleep(1000);
    JavascriptExecutor jse = (JavascriptExecutor) driver;
    jse.executeScript("document.getElementById('ap_dob').value='14/12/1992'");
    Thread.sleep(1000);
    main.findElement(By.id("ap_religion")).sendKeys("i", Keys.ENTER);
    main.findElement(By.id("ap_marital_status")).sendKeys("l", Keys.ENTER);
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step4']/div/div[12]/button[2]")).click();

    //pendidikan terakhir anda
    main.findElement(By.xpath("//*[@id='step5']/div/div[1]/div[4]/div[2]/label/span")).click();

    main.findElement(By.xpath("//*[@id='step5']/div/div[2]/button[2]")).click();

    //suku dan jumlah tanggungan anda
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step6']"));
    main.findElement(By.id("ap_race_id")).sendKeys("J", Keys.ENTER);
    main.findElement(By.id("dependents")).sendKeys("0", Keys.ENTER);
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step6']/div/div[5]/button[2]")).click();

    //nomor telepon domisili
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step7']"));
    main.findElement(By.id("ap_telp_no")).sendKeys(SupportController.createRandom(16));
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step7']/div/div[3]/button[2]")).click();

    //alamat domisili
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step8']"));
    //        main.findElement(By.id("ap_dom_address")).sendKeys("domisili selenium"+ this.email, Keys.ENTER);
    main.findElement(By.id("ap_dom_address")).sendKeys(this.alamat);
    Thread.sleep(1000);

    main.findElement(By.id("ap_dom_province")).sendKeys("DI Yogyakarta", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_dom_kab_kot")).findElement(By.cssSelector("option[value='172']")), wait);
    main.findElement(By.id("ap_dom_kab_kot")).sendKeys("Kab. Kulon Progo", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_dom_kecamatan")).findElement(By.cssSelector("option[value='423']")),
            wait);
    main.findElement(By.id("ap_dom_kecamatan")).sendKeys("Kalibawang", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_dom_kelurahan")).findElement(By.cssSelector("option[value='4398']")),
            wait);
    main.findElement(By.id("ap_dom_kelurahan")).sendKeys("Banjarasri", Keys.ENTER);
    Thread.sleep(1000);

    /*
    main.findElement(By.id("ap_dom_province")).sendKeys("Jawa Barat", Keys.ENTER);
    SupportController.waittoLoad(main.findElement(By.id("ap_dom_kab_kot")).findElement(By.cssSelector("option[value='428']")), wait);
    main.findElement(By.id("ap_dom_kab_kot")).sendKeys("Kota Depok", Keys.ENTER);
    SupportController.waittoLoad(main.findElement(By.id("ap_dom_kecamatan")).findElement(By.cssSelector("option[value='1336']")), wait);
    main.findElement(By.id("ap_dom_kecamatan")).sendKeys("Sukmajaya", Keys.ENTER);
    SupportController.waittoLoad(main.findElement(By.id("ap_dom_kelurahan")).findElement(By.cssSelector("option[value='13023']")), wait);
    main.findElement(By.id("ap_dom_kelurahan")).sendKeys("Mekarjaya", Keys.ENTER);
    Thread.sleep(1000);
     */
    main.findElement(By.xpath("//*[@id='step8']/div/div[14]/button[2]")).click();

    //status rumah
    main.findElement(By.xpath("//*[@id='step9']/div/div[1]/div[4]")).click(); //RUMAH orang tua

    main.findElement(By.xpath("//*[@id='step9']/div/div[2]/button[2]")).click();

    //data keluarga
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step10']"));
    main.findElement(By.id("ap_fam1_name")).sendKeys("keluarga selenium");
    main.findElement(By.id("ap_telp_fam1")).sendKeys(SupportController.createRandom(16));
    main.findElement(By.id("ap_fam1_address")).sendKeys("keluarga selenium");

    main.findElement(By.id("ap_fam1_province")).sendKeys("Jawa Tengah", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_fam1_kab_kot")).findElement(By.cssSelector("option[value='324']")),
            wait);
    main.findElement(By.id("ap_fam1_kab_kot")).sendKeys("Kab. Semarang", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_fam1_kecamatan")).findElement(By.cssSelector("option[value='1771']")),
            wait);
    main.findElement(By.id("ap_fam1_kecamatan")).sendKeys("Jambu", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_fam1_kelurahan")).findElement(By.cssSelector("option[value='19723']")),
            wait);
    main.findElement(By.id("ap_fam1_kelurahan")).sendKeys("Kebondalem", Keys.ENTER);
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step10']/div/div[16]/button[2]")).click();

    //data bank
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step11']"));
    SupportController.waittoLoad(
            main.findElement(By.id("ap_bank_name_id")).findElement(By.cssSelector("option[value='11']")), wait);
    main.findElement(By.id("ap_bank_name_id")).sendKeys("Bank CIMB Niaga", Keys.ENTER);
    main.findElement(By.id("ap_bank_number")).sendKeys("703553708000");
    main.findElement(By.id("ap_bank_username")).sendKeys(this.nama);

    //click checkbox
    WebElement element = main.findElement(By.id("ibc_checkbox"));
    ((JavascriptExecutor) this.driver).executeScript("arguments[0].click();", element);
    Thread.sleep(10000);
    main.findElement(By.xpath("//*[@id='step11']/div/div[7]/button[2]")).click();

    //data lokasi bekerja
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step12']"));
    main.findElement(By.id("ap_employer_name")).sendKeys("UangKawan");
    main.findElement(By.id("ap_telp_work")).sendKeys(SupportController.createRandom(15));
    main.findElement(By.id("ap_employer_address")).sendKeys("jalan casablanka ");
    Thread.sleep(1000);

    main.findElement(By.id("ap_employer_province")).sendKeys("DKI Jakarta", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_employer_kab_kot")).findElement(By.cssSelector("option[value='434']")),
            wait);
    main.findElement(By.id("ap_employer_kab_kot")).sendKeys("Kota Jakarta Selatan", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_employer_kecamatan")).findElement(By.cssSelector("option[value='491']")),
            wait);
    main.findElement(By.id("ap_employer_kecamatan")).sendKeys("Tebet", Keys.ENTER);
    SupportController.waittoLoad(main.findElement(By.id("ap_employer_kelurahan"))
            .findElement(By.cssSelector("option[value='4773']")), wait);
    main.findElement(By.id("ap_employer_kelurahan")).sendKeys("Menteng Dalam", Keys.ENTER);
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step12']/div/div[16]/button[2]")).click();

    //pekerjaan dan gaji
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step13']"));
    main.findElement(By.id("ap_mrtw_id")).sendKeys("N", Keys.ENTER);
    main.findElement(By.id("ap_employer_role")).sendKeys("Notaris");
    main.findElement(By.id("hll_years_work")).sendKeys("1", Keys.ENTER);
    main.findElement(By.id("hll_months_work")).sendKeys("3", Keys.ENTER);
    //testcase1
    main.findElement(By.id("ap_monthly_income")).sendKeys("6000000");
    main.findElement(By.id("mainexpenses")).sendKeys("2000000");
    main.findElement(By.id("houseloan")).sendKeys("0 ");

    main.findElement(By.xpath("//*[@id='step13']/div/div[15]/button[2]")).click();

    //upload dokumen
    driver.findElement(By.cssSelector("a[id='uploadBtnOther_1']")).click();

    //File Need to be imported
    File file1 = new File("/Users/rahmatzailani/Documents/index.jpg");
    StringSelection stringSelection1 = new StringSelection(file1.getAbsolutePath());
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection1, null);

    Robot robot1 = new Robot();

    // Cmd + Tab is needed since it launches a Java app and the browser looses focus

    robot1.keyPress(KeyEvent.VK_META);
    robot1.keyPress(KeyEvent.VK_TAB);
    robot1.keyRelease(KeyEvent.VK_META);
    robot1.keyRelease(KeyEvent.VK_TAB);
    robot1.delay(800);
    //Open Goto window
    robot1.keyPress(KeyEvent.VK_META);
    robot1.keyPress(KeyEvent.VK_SHIFT);
    robot1.keyPress(KeyEvent.VK_G);
    robot1.keyRelease(KeyEvent.VK_META);
    robot1.keyRelease(KeyEvent.VK_SHIFT);
    robot1.keyRelease(KeyEvent.VK_G);
    //Paste the clipboard value
    robot1.keyPress(KeyEvent.VK_META);
    robot1.keyPress(KeyEvent.VK_V);
    robot1.keyRelease(KeyEvent.VK_META);
    robot1.keyRelease(KeyEvent.VK_V);
    //Press Enter key to close the Goto window and Upload window
    robot1.keyPress(KeyEvent.VK_ENTER);
    robot1.keyRelease(KeyEvent.VK_ENTER);
    robot1.delay(800);
    robot1.keyPress(KeyEvent.VK_ENTER);
    robot1.keyRelease(KeyEvent.VK_ENTER);
    Thread.sleep(7000);

    /*
            //upload file 2
            driver.findElement(By.cssSelector("a[id='uploadBtnOther_2']")).click();
            Thread.sleep(1000);
                    
            File file2 = new File("/Users/prasetyo/Documents/Test/file upload/KTP-600x416.jpg");
            StringSelection stringSelection2= new StringSelection(file2.getAbsolutePath());
            Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection1, null);
            
            Robot robot2 = new Robot();
                    
            robot2.keyPress(KeyEvent.VK_META);
            robot2.keyPress(KeyEvent.VK_TAB);
            robot2.keyRelease(KeyEvent.VK_META);
            robot2.keyRelease(KeyEvent.VK_TAB);
            robot2.delay(800);
            //Open Goto window
            robot2.keyPress(KeyEvent.VK_META);
            robot2.keyPress(KeyEvent.VK_SHIFT);
            robot2.keyPress(KeyEvent.VK_G);
            robot2.keyRelease(KeyEvent.VK_META);
            robot2.keyRelease(KeyEvent.VK_SHIFT);
            robot2.keyRelease(KeyEvent.VK_G);
            //Paste the clipboard value
            robot2.keyPress(KeyEvent.VK_META);
            robot2.keyPress(KeyEvent.VK_V);
            robot2.keyRelease(KeyEvent.VK_META);
            robot2.keyRelease(KeyEvent.VK_V);
            //Press Enter key to close the Goto window and Upload window
            robot2.keyPress(KeyEvent.VK_ENTER);
            robot2.keyRelease(KeyEvent.VK_ENTER);
            robot2.delay(800);
            robot2.keyPress(KeyEvent.VK_ENTER);
            robot2.keyRelease(KeyEvent.VK_ENTER);
            Thread.sleep(7000);
    **/

    //upload file 3
    driver.findElement(By.cssSelector("a[id='uploadBtnOther_3']")).click();
    Thread.sleep(5000);

    File file3 = new File("/Users/rahmatzailani/Documents/index.jpg");
    StringSelection stringSelection3 = new StringSelection(file3.getAbsolutePath());
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection3, null);

    Robot robot3 = new Robot();

    robot3.keyPress(KeyEvent.VK_META);
    robot3.keyPress(KeyEvent.VK_TAB);
    robot3.keyRelease(KeyEvent.VK_META);
    robot3.keyRelease(KeyEvent.VK_TAB);
    robot3.delay(800);
    //Open Goto window
    robot3.keyPress(KeyEvent.VK_META);
    robot3.keyPress(KeyEvent.VK_SHIFT);
    robot3.keyPress(KeyEvent.VK_G);
    robot3.keyRelease(KeyEvent.VK_META);
    robot3.keyRelease(KeyEvent.VK_SHIFT);
    robot3.keyRelease(KeyEvent.VK_G);
    //Paste the clipboard value
    robot3.keyPress(KeyEvent.VK_META);
    robot3.keyPress(KeyEvent.VK_V);
    robot3.keyRelease(KeyEvent.VK_META);
    robot3.keyRelease(KeyEvent.VK_V);
    //Press Enter key to close the Goto window and Upload window
    robot3.keyPress(KeyEvent.VK_ENTER);
    robot3.keyRelease(KeyEvent.VK_ENTER);
    robot3.delay(800);
    robot3.keyPress(KeyEvent.VK_ENTER);
    robot3.keyRelease(KeyEvent.VK_ENTER);
    Thread.sleep(7000);

    //main = main.findElement(By.cssSelector("form[id='step13']"));
    //main.findElement(By.id("skip-doc")).click();
    main.findElement(By.xpath("//*[@id='step14']/div/div[5]/button[2]")).click();
    //*[@id='step14']/div/div[5]/button[2]

    //dokumen persetujuan
    Thread.sleep(15000);
    jse.executeScript("window.scrollBy(0,1000)", "");
    main.findElement(By.xpath("/html/body/div[6]/div[2]/div/div/form[15]/div/button")).click();

    //sms confirmation
    Thread.sleep(28000);
    String sms_code = (String) SupportController.getfromDatabase(
            "SELECT asp_code_sent FROM application_sms_process ORDER BY asp_sent_datetime DESC LIMIT 1;",
            this.testLocation);

    main.findElement(By.xpath("//*[@id='ap_mobile_code']")).sendKeys(sms_code, Keys.ENTER);
    //main.findElement(By.xpath("//*[@id='submit-token']/div/div[6]/button']")).click();
    //Result  
    output = true;
    System.out.println("TestScript Apply-Success");

    return output;

}

From source file:com.mycompany.newseleniumtest.TestScript.java

public void processFraud() throws InterruptedException {

    this.workbenchLogin("fraudcheck");
    WebDriverWait wait = new WebDriverWait(this.driver, 10);
    WebElement main;/*from   ww  w .ja  va 2 s  .  co  m*/
    String ap_id = SupportController.getApID(this.email, this.testLocation);
    Thread.sleep(2000);
    this.driver.manage().window().maximize();
    //error

    if (driver.getPageSource().contains(this.email)) {
        main = this.driver.findElement(By.cssSelector("a[href='https://" + this.testLocation
                + ".uangteman.com/admin/workbench/detail-fraud/" + ap_id + "']"));
        main.click();
        //      String js = String.format("window.scrollBy(%s, %s)", 100, -100);
        //      ((JavascriptExecutor) this.driver).executeScript(js);
        //      main.click();
        SupportController.waittoLoad(this.driver.findElement(By.cssSelector("a[href='#panel_tab_3']")), wait);
        this.driver.findElement(By.cssSelector("a[href='#panel_tab_3']")).click();
        this.driver.findElement(By.cssSelector("button[href='#update_fraud_modal']")).click();
        SupportController.waittoLoad(this.driver.findElement(By.id("update_fraud_modal")), wait);
        main = this.driver.findElement(By.id("update_fraud_modal"));

        main.findElement(By.cssSelector("select[name='fraud_status']")).sendKeys("N", Keys.ENTER);
        Thread.sleep(2000);
        main.findElement(By.cssSelector("textarea[name='fraud_note']")).sendKeys("AutoProcessing to CS");
        main.findElement(By.cssSelector("button[type='submit']")).click();
        Thread.sleep(5000);
    } else {
        processsupercs();
    }

}

From source file:com.mycompany.newseleniumtest.TestScript.java

public void processsupercs() throws InterruptedException {

    this.workbenchLogin("customerservice");
    WebDriverWait wait = new WebDriverWait(this.driver, 10);
    WebElement main;/*from ww w .ja  va2  s.  c  om*/
    String ap_id = SupportController.getApID(this.email, this.testLocation);
    Thread.sleep(2000);
    //ini yg dicontoh
    main = this.driver.findElement(By.cssSelector("div[class='col-md-12']"));
    main = main.findElement(By.cssSelector("div[class='panel-body']"));
    main = main.findElement(By.cssSelector("table[id='sample-table-1']"));
    this.driver.manage().window().maximize();
    Thread.sleep(2000);
    // System.out.println(ap_id);
    if (driver.getPageSource().contains(this.email)) {

        //cek element for keep window small
        main = main.findElement(By.cssSelector("a[href='#start_to_call'][call-id='" + ap_id + "']"));
        Thread.sleep(1500);
        main.click();
        main = this.driver.findElement(By.cssSelector("div[id=start_to_call]"));
        SupportController.waittoLoad(
                main.findElement(By.cssSelector("select[class='form-control phone'][name='note1']")), wait);
        main.findElement(By.cssSelector("select[class='form-control phone'][name='note1']")).sendKeys("Yes",
                Keys.ENTER);
        main.findElement(By.cssSelector("button[class='btn btn-warning btn-loading']")).click();
        Thread.sleep(5000);
    } else {
        try {
            processStaff();
        } catch (AWTException ex) {
            Logger.getLogger(TestScript.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    /*
    main = main.findElement(By.cssSelector("a[href='#start_to_call'][call-id='" + ap_id + "']"));
    main.click();
    main = this.driver.findElement(By.cssSelector("div[id=start_to_call]"));
    SupportController.waittoLoad(main.findElement(By.cssSelector("select[class='form-control phone'][name='note1']")), wait);
    main.findElement(By.cssSelector("select[class='form-control phone'][name='note1']")).sendKeys("Yes", Keys.ENTER);
    main.findElement(By.cssSelector("button[class='btn btn-warning btn-loading']")).click();
    **/

}

From source file:com.mycompany.newseleniumtest.TestScript.java

public void processStaff() throws InterruptedException, AWTException {

    this.workbenchLogin("staff");
    WebDriverWait wait = new WebDriverWait(this.driver, 10);
    WebElement main;/*w w w  .j  ava 2s  . co  m*/
    String ap_id = SupportController.getApID(this.email, this.testLocation);
    Thread.sleep(2000);

    main = this.driver.findElement(By.cssSelector("div[class='col-md-12']"));
    main = main.findElement(By.cssSelector("div[class='panel panel-default form-loading']"));
    main = main.findElement(By.cssSelector("div[class='panel-body']"));
    main = main.findElement(By.cssSelector("table[id='sample-table-1']"));
    if (driver.getPageSource().contains(this.email)) {
        this.driver.manage().window().maximize();
        Thread.sleep(2000);
        // System.out.println(ap_id);
        //if(driver.getPageSource().contains(this.email)){
        main = main.findElement(By.cssSelector("a[href='#pcs_doc'][upload-id='" + ap_id + "']"));
        main.click();
        main = this.driver.findElement(By.cssSelector("div[id=pcs_doc]"));
        SupportController.waittoLoad(main.findElement(By.cssSelector("input[id='dateSurvey']")), wait);

        main.findElement(By.cssSelector("input[id='dateSurvey']")).sendKeys("09/03/2017 1:08 PM", Keys.ENTER);

        driver.findElement(By.cssSelector("a[id='uploadBtnOther_7']")).click();
        Thread.sleep(3000);

        File file4 = new File("/Users/rahmatzailani/Documents/index.jpg");
        StringSelection stringSelection4 = new StringSelection(file4.getAbsolutePath());
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection4, null);

        Robot robot4 = new Robot();

        robot4.keyPress(KeyEvent.VK_META);
        robot4.keyPress(KeyEvent.VK_TAB);
        robot4.keyRelease(KeyEvent.VK_META);
        robot4.keyRelease(KeyEvent.VK_TAB);
        robot4.delay(500);
        //Open Goto window
        robot4.keyPress(KeyEvent.VK_META);
        robot4.keyPress(KeyEvent.VK_SHIFT);
        robot4.keyPress(KeyEvent.VK_G);
        robot4.keyRelease(KeyEvent.VK_META);
        robot4.keyRelease(KeyEvent.VK_SHIFT);
        robot4.keyRelease(KeyEvent.VK_G);
        //Paste the clipboard value
        robot4.keyPress(KeyEvent.VK_META);
        robot4.keyPress(KeyEvent.VK_V);
        robot4.keyRelease(KeyEvent.VK_META);
        robot4.keyRelease(KeyEvent.VK_V);
        //Press Enter key to close the Goto window and Upload window
        robot4.keyPress(KeyEvent.VK_ENTER);
        robot4.keyRelease(KeyEvent.VK_ENTER);
        robot4.delay(500);
        robot4.keyPress(KeyEvent.VK_ENTER);
        robot4.keyRelease(KeyEvent.VK_ENTER);
        robot4.keyPress(KeyEvent.VK_ENTER);
        robot4.keyRelease(KeyEvent.VK_ENTER);
        Thread.sleep(2000);
        main.findElement(By.cssSelector("button[class='btn btn-default refresh_table']")).click();
        Thread.sleep(5000);
    } else {
        processManager();
    }
}

From source file:com.mycompany.newseleniumtest.TestScript.java

public void Apply_Partner() throws InterruptedException {

    //masuk validasi applicant email logs

    this.startDriver("firefox");
    this.driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    WebDriverWait wait = new WebDriverWait(driver, 10);

    driver.get("https://partner-stag.uangteman.com/login");
    driver.manage().window().maximize();

    WebElement main;// w w  w. ja v  a  2  s .  c  om

    //find element intro
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("div[class='body-login']"));
    main.findElement(By.cssSelector("input[type='text']")).sendKeys("myjne001@gmail.com");
    main.findElement(By.cssSelector("input[type='password']")).sendKeys("uangteman");
    Thread.sleep(2000);
    main.findElement(By.cssSelector("button[class='btn btn-lg btn-ut-login']")).click();

    //find element alasan pinjaman
    //driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));

    //loan purpose
    main = driver.findElement(By.cssSelector("form[class='form-application']"));
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main = main.findElement(By.cssSelector("div[class='loan-purpose']"));

    main.findElement(By.id("email")).sendKeys(this.email);
    //            main.findElement(By.id("personal_id_no")).sendKeys(SupportController.createRandom(17));
    main.findElement(By.id("personal_id_no")).sendKeys(this.no_ktp);
    //          main.findElement(By.id("principal-amount-addon")).sendKeys("81210745941");
    main.findElement(By.xpath("//*[@id='form-application']/div[1]/div/div[4]/div[1]/input"))
            .sendKeys("81280085422");

    //            driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
    //            driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    main = this.driver.findElement(By.cssSelector("div[class='form-group form-group-lg']"));
    //select random reason
    //pilih div radionya yg byk
    Random rnd = new Random();
    List<WebElement> radios = driver.findElements(By.cssSelector("div[class='radio']"));
    radios.get(rnd.nextInt(radios.size())).click();

    //            Thread.sleep(10000);
    driver.manage().timeouts().pageLoadTimeout(10000, TimeUnit.SECONDS);

    main = this.driver.findElement(By.cssSelector("div[class='col-xs-12 col-md-8']"));
    main.findElement(By.cssSelector("select[id='know_ut']")).sendKeys("F", Keys.ENTER);
    main.findElement(By.xpath("//*[@id='know_ut']")).click();
    Thread.sleep(10000);
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = driver.findElement(By.cssSelector("form[class='form-application']"));
    main = this.driver.findElement(By.cssSelector("div[class='form-application-footer clearfix']"));

    main.findElement(By.cssSelector("button[class='btn btn-info pull-right btn-action']")).click();

    //personal data
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main = main.findElement(By.cssSelector("div[class='personal-data']"));

    //            main.findElement(By.id("full_name")).clear();
    main.findElement(By.id("full_name")).sendKeys("testing patner");
    //            main.findElement(By.id("pob")).clear();
    main.findElement(By.id("pob")).sendKeys("jakarta");
    //            main.findElement((By.cssSelector("div[")))

    //            main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    driver.findElement(By.xpath("//*[@id='datetimepicker']/input")).clear();
    driver.findElement(By.xpath("//*[@id='datetimepicker']/input")).sendKeys("25/12/1990", Keys.ENTER);

    //create random jenis kelamin
    Random rnd2 = new Random();
    List<WebElement> radios2 = driver.findElements(By.cssSelector("div[class='radio-gender']"));
    radios2.get(rnd2.nextInt(radios2.size())).click();

    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    //create random agama

    main = this.driver.findElement(By.cssSelector("div[class='radio-religion']"));
    main.findElement(By.cssSelector("input[id='1']")).click();
    /*
    Random rnd3 = new Random();
    List<WebElement> radios3 = driver.findElements(By.cssSelector("div[class='radio-religion']"));
    radios3.get(rnd3.nextInt(radios3.size())).click();
    */

    //select dropdown
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main.findElement(By.id("race_id")).sendKeys("J", Keys.ENTER);
    main.findElement(By.id("education")).sendKeys("S1", Keys.ENTER);

    //create random status pernikahan
    main = this.driver.findElement(By.cssSelector("div[class='radio-marital']"));
    main.findElement(By.cssSelector("input[id='1']")).click();
    /*
    Random rnd4 = new Random();
    List<WebElement> radios4 = driver.findElements(By.cssSelector("div[class='radio-marital']"));
    radios4.get(rnd4.nextInt(radios4.size())).click();
    */

    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main.findElement(By.cssSelector("input[id='dependents']")).sendKeys("0");

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

    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = main.findElement(By.cssSelector("div[class='form-application-footer clearfix']"));
    main.findElement(By.cssSelector("button[class='btn btn-info pull-right btn-action']")).click();

    //detail kontak
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));

    main.findElement(By.cssSelector("input[id='telp_no']")).sendKeys("02100929871852");
    main.findElement(By.cssSelector("textarea[id='dom_address']"))
            .sendKeys("testing street delapan delapan" + this.email);

    main = this.driver.findElement(By.cssSelector("div[class='radio-status-rumah']"));
    driver.findElement(By.xpath("//*[@id='form-application']/div[1]/div/div[5]/div[1]/div[3]/label")).click();

    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main.findElement(By.id("dom_province")).sendKeys("Jawa Barat", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("dom_city")).findElement(By.cssSelector("option[value='19']")), wait);
    main.findElement(By.id("dom_city")).sendKeys("Kab. Bandung Barat", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("dom_district")).findElement(By.cssSelector("option[value='763']")), wait);
    main.findElement(By.id("dom_district")).sendKeys("Cililin", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("dom_subdistrict")).findElement(By.cssSelector("option[value='7524']")),
            wait);
    main.findElement(By.id("dom_subdistrict")).sendKeys("Nanggerang", Keys.ENTER);

    Thread.sleep(1000);

    main.findElement(By.cssSelector("input[id='fam_name']")).sendKeys("uang teman");
    main.findElement(By.cssSelector("input[id='telp_fam1']")).sendKeys("021021100");
    main.findElement(By.cssSelector("textarea[id='fam_address']")).sendKeys("testing street fam partner");

    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main.findElement(By.id("fam_province")).sendKeys("Jawa Barat", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("fam_city")).findElement(By.cssSelector("option[value='43']")), wait);
    main.findElement(By.id("fam_city")).sendKeys("Kab. Bekasi", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("fam_district")).findElement(By.cssSelector("option[value='777']")), wait);
    main.findElement(By.id("fam_district")).sendKeys("Bojongmangu", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("fam_subdistrict")).findElement(By.cssSelector("option[value='7661']")),
            wait);
    main.findElement(By.id("fam_subdistrict")).sendKeys("Karangmulya", Keys.ENTER);

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

    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = main.findElement(By.cssSelector("div[class='form-application-footer clearfix']"));
    main.findElement(By.cssSelector("button[class='btn btn-info pull-right btn-action']")).click();

    //isi detail bank
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));

    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main = this.driver.findElement(By.cssSelector("div[class='bank-detail']"));
    main.findElement(By.id("bank_name_id")).sendKeys("Bank CIMB Niaga", Keys.ENTER);
    main.findElement(By.cssSelector("input[id='bank_number']")).sendKeys("800141863800");
    main.findElement(By.cssSelector("input[id='bank_username']")).sendKeys("testing patner");
    driver.findElement(By.xpath("//*[@id='is_bankacc_correct']")).click();

    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = main.findElement(By.cssSelector("div[class='form-application-footer clearfix']"));
    main.findElement(By.cssSelector("button[class='btn btn-info pull-right btn-action']")).click();

    //isi perkerjaan dan penghasilan
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));

    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main.findElement(By.cssSelector("input[id='office_name']")).sendKeys("pt parner uangteman");
    main.findElement(By.cssSelector("input[id='telp_work']")).sendKeys("021790098172");
    main.findElement(By.cssSelector("textarea[id='office_address']")).sendKeys("jalan menara delapan delapan");

    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main.findElement(By.id("office_province")).sendKeys("DI Yogyakarta", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("office_city")).findElement(By.cssSelector("option[value='31']")), wait);
    main.findElement(By.id("office_city")).sendKeys("Kab. Bantul", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("office_district")).findElement(By.cssSelector("option[value='388']")),
            wait);
    main.findElement(By.id("office_district")).sendKeys("Bantul", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("office_subdistrict")).findElement(By.cssSelector("option[value='4178']")),
            wait);
    main.findElement(By.id("office_subdistrict")).sendKeys("Bantul", Keys.ENTER);

    //testcase partner
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main.findElement(By.id("job_title")).sendKeys("N", Keys.ENTER);
    main.findElement(By.cssSelector("input[id='employer_role']")).sendKeys("senior");
    main.findElement(By.cssSelector("input[id='monthly_income']")).sendKeys("3000000");
    driver.findElement(By.xpath("//*[@id='startWork']/inputt")).sendKeys("25/12/2015", Keys.ENTER);
    main.findElement(By.cssSelector("input[id='mainexpenses']")).sendKeys("4000000");
    main.findElement(By.cssSelector("input[id='houseloan']")).sendKeys("0");

    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = main.findElement(By.cssSelector("div[class='form-application-footer clearfix']"));
    main.findElement(By.cssSelector("button[class='btn btn-info pull-right btn-action']")).click();

    //dokumen persetujuan
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));

    //confirmation dokumen persetujuan
    main = main.findElement(By.cssSelector("div[class='doc-agreement-footer clearfix']"));
    main.findElement(By.cssSelector("button[class='btn btn-info pull-rightt']")).click();
    Thread.sleep(10000);

    //            main = this.driver.findElement(By.cssSelector("div[class='sweet-overlay']"));
    main = this.driver.findElement(By.cssSelector("div[class='sweet-alert showSweetAlert visible']"));
    main = this.driver.findElement(By.cssSelector("div[class='sa-confirm-button-container']"));
    main.findElement(By.cssSelector("button[class='confirm']")).click();
    Thread.sleep(1000);
}

From source file:com.mycompany.newseleniumtest.TestScript2.java

public boolean Apply_new() throws InterruptedException, AWTException {
    boolean output = false;
    this.startDriver("firefox");
    WebDriverWait wait = new WebDriverWait(this.driver, 10);

    //Open the page
    if (this.testLocation.equals("local")) {
        this.driver.get("localhost:80/uang-teman/");
    } else //  this.driver.get("https://dev.uangteman.com/___organic"); 
    {/* w  w  w. j a  v  a 2s.c o  m*/
        if (this.isCampaign) {
            this.driver.get("https://" + this.testLocation + ".uangteman.com/" + campaign);
        } else {
            //                this.driver.get("https://hotfix.uangteman.com");
            this.driver.get("https://" + this.testLocation + ".uangteman.com/"); //https://dev.uangteman.com/a/NHeHv
        }
    }

    WebElement main;

    //IntroPage

    //        main=driver.findElement(By.cssSelector("div[id='pinjaman-side'"));
    //        Point point = main.getLocation();
    //        int xcord = point.getX();
    //        System.out.println("Element's Position from left side Is "+xcord +" pixels.");
    //        int ycord = point.getY();
    //        System.out.println("Element's Position from top side Is "+ycord +" pixels.");
    //        main = this.driver.findElement(By.cssSelector("div[id='pinjaman-side']"));
    //        main = this.driver.findElement(By.cssSelector("div[id='ajukan-pinjaman-box']"));

    if (this.testLocation.equals("hotfix")) {
        Thread.sleep(5000);
        main = this.driver.findElement(By.id("colorbox"));
        //main = driver.findElement(By.cssSelector("div[id='colorbox']")); 
        //main = this.driver.findElement(By.id("colorbox"));
        main.findElement(By.cssSelector("button[id='cboxClose']")).click();
        Thread.sleep(3000);
        main = this.driver.findElement(By.cssSelector("div[id='home']"));
        main = this.driver.findElement(By.cssSelector("div[id='ajukan-pinjaman-box']"));
        main.findElement(By.cssSelector("a[href='https://hotfix.uangteman.com/loan-calculator")).click();

    } else {
        if (this.testLocation.equals("dev")) {
            Thread.sleep(5000);
            main = this.driver.findElement(By.id("colorbox"));
            main.findElement(By.cssSelector("button[id='cboxClose']")).click();
            Thread.sleep(3000);
            main = this.driver.findElement(By.cssSelector("div[id='home']"));
            main = this.driver.findElement(By.cssSelector("div[id='ajukan-pinjaman-box']"));
            main.findElement(By.cssSelector("a[href='https://dev.uangteman.com/loan-calculator")).click();
        } else {
            Thread.sleep(5000);
            main = this.driver.findElement(By.id("colorbox"));
            main.findElement(By.cssSelector("button[id='cboxClose']")).click();
            Thread.sleep(3000);
            main = this.driver.findElement(By.cssSelector("div[id='home']"));
            main = this.driver.findElement(By.cssSelector("div[id='ajukan-pinjaman-box']"));
            main.findElement(By.cssSelector("a[href='https://staging.uangteman.com/loan-calculator")).click();
        }
    }

    /* 
    main = this.driver.findElement(By.cssSelector("div[id='pinjaman-side']"));
            
    // case when
    main.findElement(By.cssSelector("a[href='https://hotfix.uangteman.com/loan-calculator")).click();
    **/

    //calculator
    //main.findElement(By.id("ap_email_address")).clear();
    main = driver.findElement(By.cssSelector("div[class='container']"));
    main = driver.findElement(By.cssSelector("div[class='row']"));
    main = driver.findElement(By.cssSelector("div[class='col-xs-12']"));
    main = driver.findElement(By.cssSelector("form[id='form-calculator']"));
    main = driver.findElement(By.cssSelector("div[class='ut-form-container']"));
    main = driver.findElement(By.cssSelector("div[class='ut-form-box1']"));
    /*
    //start slide
    WebElement dragElementFrom = driver.findElement(By.xpath("//span[contains(@class, 'ui-slider-handle')]")); 
            
    new Actions(driver).dragAndDropBy(dragElementFrom, 100, 0).build().perform();
    Thread.sleep(5000);
    //end slide
    new Actions(driver).clickAndHold(dragElementFrom).moveByOffset(100,0).release().perform();
    **/

    if (this.isPromo) {
        main.findElement(By.id("promo_code")).sendKeys(this.promo_code, Keys.ENTER);
        Thread.sleep(4000);
    }

    Thread.sleep(4000);
    main.findElement(By.cssSelector("a[class='btn btn-medium monserat btn-pinjam-sekarang']")).click();

    //term and condition
    main = driver.findElement(By.cssSelector("div[class='container']"));
    main = driver.findElement(By.cssSelector("form[id='agreement-form']"));
    main = driver.findElement(By.cssSelector("div[class='col-md-12 ut-form-container']"));
    main.findElement(By.cssSelector("button[id='checklist-button']")).click();
    //        main.findElement(By.id("ajukan-pinjaman-final")).submit();
    Thread.sleep(1000);

    //detail kontak
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main.findElement(By.id("ap_email_address")).clear();
    main.findElement(By.id("ap_email_address")).sendKeys(this.email);
    main.findElement(By.id("ap_mobile_no")).clear();
    main.findElement(By.id("ap_mobile_no")).sendKeys("82288724193");
    main.findElement(By.id("ap_personal_id_no")).clear();
    main.findElement(By.id("ap_personal_id_no")).sendKeys("3174041211920005");
    //        main.findElement(By.id("ap_personal_id_no")).sendKeys(SupportController.createRandom(17));
    Thread.sleep(1000);

    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = driver.findElement(By.cssSelector("form[id='step1']"));
    main = driver.findElement(By.cssSelector("div[class='ut-form-box2 clearfix']"));
    main.findElement(By.cssSelector("button[class='btn-next']")).click();
    Thread.sleep(11000);

    //form purpose loan
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = driver.findElement(By.cssSelector("form[id='step2']"));
    main = driver.findElement(By.cssSelector("div[class='ut-form-box2 clearfix']"));
    main = driver.findElement(By.cssSelector("div[class='ut-form-content']"));
    main = driver.findElement(By.cssSelector("div[class='selection-box-first']"));
    main.findElement(By.cssSelector("div[class='selection-radio']")).click();
    Thread.sleep(1000);

    driver.findElement(By.xpath("//*[@id='step2']/div/div[2]/button[2]")).click();

    //form know ut
    driver.findElement(By.xpath("//*[@id='step3']/div/div[1]/div[1]/div[2]/label/span")).click();

    driver.findElement(By.xpath("//*[@id='step3']/div/div[2]/button[2]")).click();
    Thread.sleep(1000);

    //more detail kontak
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step4']"));
    main.findElement(By.id("ap_full_name")).clear();
    main.findElement(By.id("ap_full_name")).sendKeys(this.nama);
    main.findElement(By.id("ap_gender")).sendKeys("l", Keys.ENTER);
    main.findElement(By.id("ap_pob")).clear();
    main.findElement(By.id("ap_pob")).sendKeys("Jakarta");
    Thread.sleep(1000);
    JavascriptExecutor jse = (JavascriptExecutor) driver;
    jse.executeScript("document.getElementById('ap_dob').value='12/11/1992'");
    Thread.sleep(1000);
    main.findElement(By.id("ap_religion")).sendKeys("k", Keys.ENTER);
    main.findElement(By.id("ap_marital_status")).sendKeys("l", Keys.ENTER);
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step4']/div/div[12]/button[2]")).click();

    //pendidikan terakhir anda
    main.findElement(By.xpath("//*[@id='step5']/div/div[1]/div[4]/div[2]/label/span")).click();

    main.findElement(By.xpath("//*[@id='step5']/div/div[2]/button[2]")).click();

    //suku dan jumlah tanggungan anda
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step6']"));
    main.findElement(By.id("ap_race_id")).sendKeys("J", Keys.ENTER);
    main.findElement(By.id("dependents")).sendKeys("0", Keys.ENTER);
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step6']/div/div[5]/button[2]")).click();

    //nomor telepon domisili
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step7']"));
    main.findElement(By.id("ap_telp_no")).sendKeys(SupportController.createRandom(16));
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step7']/div/div[3]/button[2]")).click();

    //alamat domisili
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step8']"));
    //        main.findElement(By.id("ap_dom_address")).sendKeys("domisili selenium"+ this.email, Keys.ENTER);
    main.findElement(By.id("ap_dom_address")).sendKeys(this.alamat);
    Thread.sleep(1000);

    main.findElement(By.id("ap_dom_province")).sendKeys("DKI Jakarta", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_dom_kab_kot")).findElement(By.cssSelector("option[value='434']")), wait);
    main.findElement(By.id("ap_dom_kab_kot")).sendKeys("Kota Jakarta Selatan", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_dom_kecamatan")).findElement(By.cssSelector("option[value='488']")),
            wait);
    main.findElement(By.id("ap_dom_kecamatan")).sendKeys("Pasar Minggu", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_dom_kelurahan")).findElement(By.cssSelector("option[value='4753']")),
            wait);
    main.findElement(By.id("ap_dom_kelurahan")).sendKeys("Pejaten Barat", Keys.ENTER);
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step8']/div/div[14]/button[2]")).click();

    //status rumah
    main.findElement(By.xpath("//*[@id='step9']/div/div[1]/div[4]")).click(); //RUMAH orang tua

    main.findElement(By.xpath("//*[@id='step9']/div/div[2]/button[2]")).click();

    //data keluarga
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step10']"));
    main.findElement(By.id("ap_fam1_name")).sendKeys("keluarga selenium");
    main.findElement(By.id("ap_telp_fam1")).sendKeys(SupportController.createRandom(16));
    main.findElement(By.id("ap_fam1_address")).sendKeys("keluarga selenium");

    main.findElement(By.id("ap_fam1_province")).sendKeys("Jawa Tengah", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_fam1_kab_kot")).findElement(By.cssSelector("option[value='324']")),
            wait);
    main.findElement(By.id("ap_fam1_kab_kot")).sendKeys("Kab. Semarang", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_fam1_kecamatan")).findElement(By.cssSelector("option[value='1771']")),
            wait);
    main.findElement(By.id("ap_fam1_kecamatan")).sendKeys("Jambu", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_fam1_kelurahan")).findElement(By.cssSelector("option[value='19723']")),
            wait);
    main.findElement(By.id("ap_fam1_kelurahan")).sendKeys("Kebondalem", Keys.ENTER);
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step10']/div/div[16]/button[2]")).click();

    //data bank
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step11']"));
    SupportController.waittoLoad(
            main.findElement(By.id("ap_bank_name_id")).findElement(By.cssSelector("option[value='11']")), wait);
    main.findElement(By.id("ap_bank_name_id")).sendKeys("Bank CIMB Niaga", Keys.ENTER);
    main.findElement(By.id("ap_bank_number")).sendKeys("703553708000");
    main.findElement(By.id("ap_bank_username")).sendKeys(this.nama);

    //click checkbox
    WebElement element = main.findElement(By.id("ibc_checkbox"));
    ((JavascriptExecutor) this.driver).executeScript("arguments[0].click();", element);
    Thread.sleep(10000);
    main.findElement(By.xpath("//*[@id='step11']/div/div[7]/button[2]")).click();

    //data lokasi bekerja
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step12']"));
    main.findElement(By.id("ap_employer_name")).sendKeys("perusahaan testing");
    main.findElement(By.id("ap_telp_work")).sendKeys(SupportController.createRandom(15));
    main.findElement(By.id("ap_employer_address")).sendKeys("jalan selenium uanggeman");
    Thread.sleep(1000);

    main.findElement(By.id("ap_employer_province")).sendKeys("Jawa Barat", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_employer_kab_kot")).findElement(By.cssSelector("option[value='61']")),
            wait);
    main.findElement(By.id("ap_employer_kab_kot")).sendKeys("Kab. Bogor", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("ap_employer_kecamatan")).findElement(By.cssSelector("option[value='800']")),
            wait);
    main.findElement(By.id("ap_employer_kecamatan")).sendKeys("Bojonggede", Keys.ENTER);
    SupportController.waittoLoad(main.findElement(By.id("ap_employer_kelurahan"))
            .findElement(By.cssSelector("option[value='7847']")), wait);
    main.findElement(By.id("ap_employer_kelurahan")).sendKeys("Bojong Gede", Keys.ENTER);
    Thread.sleep(1000);

    main.findElement(By.xpath("//*[@id='step12']/div/div[16]/button[2]")).click();

    //pekerjaan dan gaji
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step13']"));
    main.findElement(By.id("ap_mrtw_id")).sendKeys("N", Keys.ENTER);
    main.findElement(By.id("ap_employer_role")).sendKeys("Notaris");
    main.findElement(By.id("hll_years_work")).sendKeys("1", Keys.ENTER);
    main.findElement(By.id("hll_months_work")).sendKeys("3", Keys.ENTER);
    //testcase1
    main.findElement(By.id("ap_monthly_income")).sendKeys("9000000");
    main.findElement(By.id("mainexpenses")).sendKeys("2000000");
    main.findElement(By.id("houseloan")).sendKeys("0");

    main.findElement(By.xpath("//*[@id='step13']/div/div[15]/button[2]")).click();

    //upload dokumen
    driver.findElement(By.cssSelector("a[id='uploadBtnOther_1']")).click();

    //File Need to be imported
    File file1 = new File("/Users/prasetyo/Documents/Test/file upload/KTP SAYA.png");
    StringSelection stringSelection1 = new StringSelection(file1.getAbsolutePath());
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection1, null);

    Robot robot1 = new Robot();

    // Cmd + Tab is needed since it launches a Java app and the browser looses focus

    robot1.keyPress(KeyEvent.VK_META);
    robot1.keyPress(KeyEvent.VK_TAB);
    robot1.keyRelease(KeyEvent.VK_META);
    robot1.keyRelease(KeyEvent.VK_TAB);
    robot1.delay(800);
    //Open Goto window
    robot1.keyPress(KeyEvent.VK_META);
    robot1.keyPress(KeyEvent.VK_SHIFT);
    robot1.keyPress(KeyEvent.VK_G);
    robot1.keyRelease(KeyEvent.VK_META);
    robot1.keyRelease(KeyEvent.VK_SHIFT);
    robot1.keyRelease(KeyEvent.VK_G);
    //Paste the clipboard value
    robot1.keyPress(KeyEvent.VK_META);
    robot1.keyPress(KeyEvent.VK_V);
    robot1.keyRelease(KeyEvent.VK_META);
    robot1.keyRelease(KeyEvent.VK_V);
    //Press Enter key to close the Goto window and Upload window
    robot1.keyPress(KeyEvent.VK_ENTER);
    robot1.keyRelease(KeyEvent.VK_ENTER);
    robot1.delay(800);
    robot1.keyPress(KeyEvent.VK_ENTER);
    robot1.keyRelease(KeyEvent.VK_ENTER);
    Thread.sleep(7000);

    /*
            //upload file 2
            driver.findElement(By.cssSelector("a[id='uploadBtnOther_2']")).click();
            Thread.sleep(1000);
                    
            File file2 = new File("/Users/prasetyo/Documents/Test/file upload/KTP-600x416.jpg");
            StringSelection stringSelection2= new StringSelection(file2.getAbsolutePath());
            Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection1, null);
            
            Robot robot2 = new Robot();
                    
            robot2.keyPress(KeyEvent.VK_META);
            robot2.keyPress(KeyEvent.VK_TAB);
            robot2.keyRelease(KeyEvent.VK_META);
            robot2.keyRelease(KeyEvent.VK_TAB);
            robot2.delay(800);
            //Open Goto window
            robot2.keyPress(KeyEvent.VK_META);
            robot2.keyPress(KeyEvent.VK_SHIFT);
            robot2.keyPress(KeyEvent.VK_G);
            robot2.keyRelease(KeyEvent.VK_META);
            robot2.keyRelease(KeyEvent.VK_SHIFT);
            robot2.keyRelease(KeyEvent.VK_G);
            //Paste the clipboard value
            robot2.keyPress(KeyEvent.VK_META);
            robot2.keyPress(KeyEvent.VK_V);
            robot2.keyRelease(KeyEvent.VK_META);
            robot2.keyRelease(KeyEvent.VK_V);
            //Press Enter key to close the Goto window and Upload window
            robot2.keyPress(KeyEvent.VK_ENTER);
            robot2.keyRelease(KeyEvent.VK_ENTER);
            robot2.delay(800);
            robot2.keyPress(KeyEvent.VK_ENTER);
            robot2.keyRelease(KeyEvent.VK_ENTER);
            Thread.sleep(7000);
    **/

    //upload file 3
    driver.findElement(By.cssSelector("a[id='uploadBtnOther_3']")).click();
    Thread.sleep(5000);

    File file3 = new File("/Users/prasetyo/Documents/Test/file upload/KTP SAYA.png");
    StringSelection stringSelection3 = new StringSelection(file3.getAbsolutePath());
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection3, null);

    Robot robot3 = new Robot();

    robot3.keyPress(KeyEvent.VK_META);
    robot3.keyPress(KeyEvent.VK_TAB);
    robot3.keyRelease(KeyEvent.VK_META);
    robot3.keyRelease(KeyEvent.VK_TAB);
    robot3.delay(800);
    //Open Goto window
    robot3.keyPress(KeyEvent.VK_META);
    robot3.keyPress(KeyEvent.VK_SHIFT);
    robot3.keyPress(KeyEvent.VK_G);
    robot3.keyRelease(KeyEvent.VK_META);
    robot3.keyRelease(KeyEvent.VK_SHIFT);
    robot3.keyRelease(KeyEvent.VK_G);
    //Paste the clipboard value
    robot3.keyPress(KeyEvent.VK_META);
    robot3.keyPress(KeyEvent.VK_V);
    robot3.keyRelease(KeyEvent.VK_META);
    robot3.keyRelease(KeyEvent.VK_V);
    //Press Enter key to close the Goto window and Upload window
    robot3.keyPress(KeyEvent.VK_ENTER);
    robot3.keyRelease(KeyEvent.VK_ENTER);
    robot3.delay(800);
    robot3.keyPress(KeyEvent.VK_ENTER);
    robot3.keyRelease(KeyEvent.VK_ENTER);
    Thread.sleep(7000);

    //main = main.findElement(By.cssSelector("form[id='step13']"));
    //main.findElement(By.id("skip-doc")).click();
    main.findElement(By.xpath("//*[@id='step14']/div/div[5]/button[2]")).click();
    //*[@id='step14']/div/div[5]/button[2]

    //dokumen persetujuan
    main = driver.findElement(By.cssSelector("div[id='applicant-form']"));
    main = main.findElement(By.cssSelector("form[id='step15']"));
    main.findElement(By.cssSelector("button[class='btn-agreement1']")).click();

    //sms confirmation
    Thread.sleep(15000);
    String sms_code = (String) SupportController.getfromDatabase(
            "SELECT asp_code_sent FROM application_sms_process ORDER BY asp_sent_datetime DESC LIMIT 1;",
            this.testLocation);

    main.findElement(By.xpath("//*[@id='ap_mobile_code']")).sendKeys(sms_code, Keys.ENTER);
    //main.findElement(By.xpath("//*[@id='submit-token']/div/div[6]/button']")).click();
    //Result  
    output = true;
    System.out.println("TestScript Apply-Success");

    return output;

}

From source file:com.mycompany.newseleniumtest.TestScript2.java

public void processsupercs() throws InterruptedException {

    this.workbenchLogin("customerservice");
    WebDriverWait wait = new WebDriverWait(this.driver, 10);
    WebElement main;// www  .  jav a  2 s  . c  om
    String ap_id = SupportController.getApID(this.email, this.testLocation);
    Thread.sleep(2000);
    //ini yg dicontoh
    main = this.driver.findElement(By.cssSelector("div[class='col-md-12']"));
    main = main.findElement(By.cssSelector("div[class='panel-body']"));
    main = main.findElement(By.cssSelector("table[id='sample-table-1']"));
    this.driver.manage().window().maximize();
    Thread.sleep(2000);
    // System.out.println(ap_id);
    if (driver.getPageSource().contains(this.email)) {
        main = main.findElement(By.cssSelector("a[href='#start_to_call'][call-id='" + ap_id + "']"));
        main.click();
        main = this.driver.findElement(By.cssSelector("div[id=start_to_call]"));
        SupportController.waittoLoad(
                main.findElement(By.cssSelector("select[class='form-control phone'][name='note1']")), wait);
        main.findElement(By.cssSelector("select[class='form-control phone'][name='note1']")).sendKeys("Yes",
                Keys.ENTER);
        main.findElement(By.cssSelector("button[class='btn btn-warning btn-loading']")).click();
        Thread.sleep(5000);
    } else {
        try {
            processStaff();
        } catch (AWTException ex) {
            Logger.getLogger(TestScript.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    /*
    main = main.findElement(By.cssSelector("a[href='#start_to_call'][call-id='" + ap_id + "']"));
    main.click();
    main = this.driver.findElement(By.cssSelector("div[id=start_to_call]"));
    SupportController.waittoLoad(main.findElement(By.cssSelector("select[class='form-control phone'][name='note1']")), wait);
    main.findElement(By.cssSelector("select[class='form-control phone'][name='note1']")).sendKeys("Yes", Keys.ENTER);
    main.findElement(By.cssSelector("button[class='btn btn-warning btn-loading']")).click();
    **/

}

From source file:com.mycompany.newseleniumtest.TestScript2.java

public void processStaff() throws InterruptedException, AWTException {

    this.workbenchLogin("staff");
    WebDriverWait wait = new WebDriverWait(this.driver, 10);
    WebElement main;/*  w ww  .  jav  a  2 s.c o  m*/
    String ap_id = SupportController.getApID(this.email, this.testLocation);
    Thread.sleep(2000);

    main = this.driver.findElement(By.cssSelector("div[class='col-md-12']"));
    main = main.findElement(By.cssSelector("div[class='panel panel-default form-loading']"));
    main = main.findElement(By.cssSelector("div[class='panel-body']"));
    main = main.findElement(By.cssSelector("table[id='sample-table-1']"));
    if (driver.getPageSource().contains(this.email)) {
        this.driver.manage().window().maximize();
        Thread.sleep(2000);
        // System.out.println(ap_id);
        //if(driver.getPageSource().contains(this.email)){
        main = main.findElement(By.cssSelector("a[href='#pcs_doc'][upload-id='" + ap_id + "']"));
        main.click();
        main = this.driver.findElement(By.cssSelector("div[id=pcs_doc]"));
        SupportController.waittoLoad(main.findElement(By.cssSelector("input[id='dateSurvey']")), wait);

        main.findElement(By.cssSelector("input[id='dateSurvey']")).sendKeys("02/01/2016 1:08 PM", Keys.ENTER);

        driver.findElement(By.cssSelector("a[id='uploadBtnOther_7']")).click();
        Thread.sleep(3000);

        File file4 = new File("/Users/prasetyo/Documents/Test/file upload/KTP-600x416.jpg");
        StringSelection stringSelection4 = new StringSelection(file4.getAbsolutePath());
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection4, null);

        Robot robot4 = new Robot();

        robot4.keyPress(KeyEvent.VK_META);
        robot4.keyPress(KeyEvent.VK_TAB);
        robot4.keyRelease(KeyEvent.VK_META);
        robot4.keyRelease(KeyEvent.VK_TAB);
        robot4.delay(500);
        //Open Goto window
        robot4.keyPress(KeyEvent.VK_META);
        robot4.keyPress(KeyEvent.VK_SHIFT);
        robot4.keyPress(KeyEvent.VK_G);
        robot4.keyRelease(KeyEvent.VK_META);
        robot4.keyRelease(KeyEvent.VK_SHIFT);
        robot4.keyRelease(KeyEvent.VK_G);
        //Paste the clipboard value
        robot4.keyPress(KeyEvent.VK_META);
        robot4.keyPress(KeyEvent.VK_V);
        robot4.keyRelease(KeyEvent.VK_META);
        robot4.keyRelease(KeyEvent.VK_V);
        //Press Enter key to close the Goto window and Upload window
        robot4.keyPress(KeyEvent.VK_ENTER);
        robot4.keyRelease(KeyEvent.VK_ENTER);
        robot4.delay(500);
        robot4.keyPress(KeyEvent.VK_ENTER);
        robot4.keyRelease(KeyEvent.VK_ENTER);
        robot4.keyPress(KeyEvent.VK_ENTER);
        robot4.keyRelease(KeyEvent.VK_ENTER);
        Thread.sleep(2000);
        main.findElement(By.cssSelector("button[class='btn btn-default refresh_table']")).click();
        Thread.sleep(5000);
    } else {
        processManager();
    }
}

From source file:com.mycompany.newseleniumtest.TestScript2.java

public void Apply_Partner() throws InterruptedException {

    //masuk validasi applicant email logs

    this.startDriver("firefox");
    this.driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    WebDriverWait wait = new WebDriverWait(driver, 10);

    driver.get("https://partner-stag.uangteman.com/login");
    driver.manage().window().maximize();

    WebElement main;//  w ww .  ja  va 2s  .  co m

    //find element intro
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("div[class='body-login']"));
    main.findElement(By.cssSelector("input[type='text']")).sendKeys("myjne001@gmail.com");
    main.findElement(By.cssSelector("input[type='password']")).sendKeys("uangteman");
    Thread.sleep(2000);
    main.findElement(By.cssSelector("button[class='btn btn-lg btn-ut-login']")).click();

    //find element alasan pinjaman
    //driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));

    //loan purpose
    main = driver.findElement(By.cssSelector("form[class='form-application']"));
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main = main.findElement(By.cssSelector("div[class='loan-purpose']"));

    main.findElement(By.id("email")).sendKeys(this.email);
    //            main.findElement(By.id("personal_id_no")).sendKeys(SupportController.createRandom(17));
    main.findElement(By.id("personal_id_no")).sendKeys("3174041211920005");
    //          main.findElement(By.id("principal-amount-addon")).sendKeys("81210745941");
    main.findElement(By.xpath("//*[@id='form-application']/div[1]/div/div[4]/div[1]/input"))
            .sendKeys("81280085422");

    //            driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
    //            driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    main = this.driver.findElement(By.cssSelector("div[class='form-group form-group-lg']"));
    //select random reason
    //pilih div radionya yg byk
    Random rnd = new Random();
    List<WebElement> radios = driver.findElements(By.cssSelector("div[class='radio']"));
    radios.get(rnd.nextInt(radios.size())).click();

    //            Thread.sleep(10000);
    driver.manage().timeouts().pageLoadTimeout(10000, TimeUnit.SECONDS);

    main = this.driver.findElement(By.cssSelector("div[class='col-xs-12 col-md-8']"));
    main.findElement(By.cssSelector("select[id='know_ut']")).sendKeys("F", Keys.ENTER);
    main.findElement(By.xpath("//*[@id='know_ut']")).click();
    Thread.sleep(10000);
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = driver.findElement(By.cssSelector("form[class='form-application']"));
    main = this.driver.findElement(By.cssSelector("div[class='form-application-footer clearfix']"));

    main.findElement(By.cssSelector("button[class='btn btn-info pull-right btn-action']")).click();

    //personal data
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main = main.findElement(By.cssSelector("div[class='personal-data']"));

    //            main.findElement(By.id("full_name")).clear();
    main.findElement(By.id("full_name")).sendKeys("testing patner");
    //            main.findElement(By.id("pob")).clear();
    main.findElement(By.id("pob")).sendKeys("jakarta");
    //            main.findElement((By.cssSelector("div[")))

    //            main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    driver.findElement(By.xpath("//*[@id='datetimepicker']/input")).clear();
    driver.findElement(By.xpath("//*[@id='datetimepicker']/input")).sendKeys("25/12/1990", Keys.ENTER);

    //create random jenis kelamin
    Random rnd2 = new Random();
    List<WebElement> radios2 = driver.findElements(By.cssSelector("div[class='radio-gender']"));
    radios2.get(rnd2.nextInt(radios2.size())).click();

    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    //create random agama

    main = this.driver.findElement(By.cssSelector("div[class='radio-religion']"));
    main.findElement(By.cssSelector("input[id='1']")).click();
    /*
    Random rnd3 = new Random();
    List<WebElement> radios3 = driver.findElements(By.cssSelector("div[class='radio-religion']"));
    radios3.get(rnd3.nextInt(radios3.size())).click();
    */

    //select dropdown
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main.findElement(By.id("race_id")).sendKeys("J", Keys.ENTER);
    main.findElement(By.id("education")).sendKeys("S1", Keys.ENTER);

    //create random status pernikahan
    main = this.driver.findElement(By.cssSelector("div[class='radio-marital']"));
    main.findElement(By.cssSelector("input[id='1']")).click();
    /*
    Random rnd4 = new Random();
    List<WebElement> radios4 = driver.findElements(By.cssSelector("div[class='radio-marital']"));
    radios4.get(rnd4.nextInt(radios4.size())).click();
    */

    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main.findElement(By.cssSelector("input[id='dependents']")).sendKeys("0");

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

    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = main.findElement(By.cssSelector("div[class='form-application-footer clearfix']"));
    main.findElement(By.cssSelector("button[class='btn btn-info pull-right btn-action']")).click();

    //detail kontak
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));

    main.findElement(By.cssSelector("input[id='telp_no']")).sendKeys("02100929871852");
    main.findElement(By.cssSelector("textarea[id='dom_address']"))
            .sendKeys("testing street delapan delapan" + this.email);

    main = this.driver.findElement(By.cssSelector("div[class='radio-status-rumah']"));
    driver.findElement(By.xpath("//*[@id='form-application']/div[1]/div/div[5]/div[1]/div[3]/label")).click();

    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main.findElement(By.id("dom_province")).sendKeys("Jawa Barat", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("dom_city")).findElement(By.cssSelector("option[value='19']")), wait);
    main.findElement(By.id("dom_city")).sendKeys("Kab. Bandung Barat", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("dom_district")).findElement(By.cssSelector("option[value='763']")), wait);
    main.findElement(By.id("dom_district")).sendKeys("Cililin", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("dom_subdistrict")).findElement(By.cssSelector("option[value='7524']")),
            wait);
    main.findElement(By.id("dom_subdistrict")).sendKeys("Nanggerang", Keys.ENTER);

    Thread.sleep(1000);

    main.findElement(By.cssSelector("input[id='fam_name']")).sendKeys("uang teman");
    main.findElement(By.cssSelector("input[id='telp_fam1']")).sendKeys("021021100");
    main.findElement(By.cssSelector("textarea[id='fam_address']")).sendKeys("testing street fam partner");

    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main.findElement(By.id("fam_province")).sendKeys("Jawa Barat", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("fam_city")).findElement(By.cssSelector("option[value='43']")), wait);
    main.findElement(By.id("fam_city")).sendKeys("Kab. Bekasi", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("fam_district")).findElement(By.cssSelector("option[value='777']")), wait);
    main.findElement(By.id("fam_district")).sendKeys("Bojongmangu", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("fam_subdistrict")).findElement(By.cssSelector("option[value='7661']")),
            wait);
    main.findElement(By.id("fam_subdistrict")).sendKeys("Karangmulya", Keys.ENTER);

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

    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = main.findElement(By.cssSelector("div[class='form-application-footer clearfix']"));
    main.findElement(By.cssSelector("button[class='btn btn-info pull-right btn-action']")).click();

    //isi detail bank
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));

    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main = this.driver.findElement(By.cssSelector("div[class='bank-detail']"));
    main.findElement(By.id("bank_name_id")).sendKeys("Bank CIMB Niaga", Keys.ENTER);
    main.findElement(By.cssSelector("input[id='bank_number']")).sendKeys("703553708000");
    main.findElement(By.cssSelector("input[id='bank_username']")).sendKeys("testing patner");
    driver.findElement(By.xpath("//*[@id='is_bankacc_correct']")).click();

    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = main.findElement(By.cssSelector("div[class='form-application-footer clearfix']"));
    main.findElement(By.cssSelector("button[class='btn btn-info pull-right btn-action']")).click();

    //isi perkerjaan dan penghasilan
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));

    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main.findElement(By.cssSelector("input[id='office_name']")).sendKeys("pt parner uangteman");
    main.findElement(By.cssSelector("input[id='telp_work']")).sendKeys("021790098172");
    main.findElement(By.cssSelector("textarea[id='office_address']")).sendKeys("jalan menara delapan delapan");

    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main.findElement(By.id("office_province")).sendKeys("DI Yogyakarta", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("office_city")).findElement(By.cssSelector("option[value='31']")), wait);
    main.findElement(By.id("office_city")).sendKeys("Kab. Bantul", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("office_district")).findElement(By.cssSelector("option[value='388']")),
            wait);
    main.findElement(By.id("office_district")).sendKeys("Bantul", Keys.ENTER);
    SupportController.waittoLoad(
            main.findElement(By.id("office_subdistrict")).findElement(By.cssSelector("option[value='4178']")),
            wait);
    main.findElement(By.id("office_subdistrict")).sendKeys("Bantul", Keys.ENTER);

    //testcase partner
    main = this.driver.findElement(By.cssSelector("div[class='form-application-body']"));
    main.findElement(By.id("job_title")).sendKeys("N", Keys.ENTER);
    main.findElement(By.cssSelector("input[id='employer_role']")).sendKeys("senior");
    main.findElement(By.cssSelector("input[id='monthly_income']")).sendKeys("3000000");
    driver.findElement(By.xpath("//*[@id='startWork']/inputt")).sendKeys("25/12/2015", Keys.ENTER);
    main.findElement(By.cssSelector("input[id='mainexpenses']")).sendKeys("4000000");
    main.findElement(By.cssSelector("input[id='houseloan']")).sendKeys("0");

    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));
    main = main.findElement(By.cssSelector("div[class='form-application-footer clearfix']"));
    main.findElement(By.cssSelector("button[class='btn btn-info pull-right btn-action']")).click();

    //dokumen persetujuan
    main = this.driver.findElement(By.id("app"));
    main = this.driver.findElement(By.cssSelector("div[class='wrapper grey']"));
    main = this.driver.findElement(By.cssSelector("div[class='container']"));
    main = this.driver.findElement(By.cssSelector("form[class='form-application']"));

    //confirmation dokumen persetujuan
    main = main.findElement(By.cssSelector("div[class='doc-agreement-footer clearfix']"));
    main.findElement(By.cssSelector("button[class='btn btn-info pull-rightt']")).click();
    Thread.sleep(10000);

    //            main = this.driver.findElement(By.cssSelector("div[class='sweet-overlay']"));
    main = this.driver.findElement(By.cssSelector("div[class='sweet-alert showSweetAlert visible']"));
    main = this.driver.findElement(By.cssSelector("div[class='sa-confirm-button-container']"));
    main.findElement(By.cssSelector("button[class='confirm']")).click();
    Thread.sleep(1000);
}