Beispiel #1
0
 public static void Login(DefaultSelenium sClient, String username, String password)
     throws Exception {
   sClient.open("/");
   sClient.type("username", username);
   sClient.type("__ac_password", password);
   sClient.click("submitbutton");
   sClient.waitForPageToLoad("40000");
 }
  /** @param args */
  public static void main(String[] args) {

    DefaultSelenium selenium =
        new DefaultSelenium("localhost", 4444, "*firefox", "http://www.hdfcbank.com/");
    selenium.start();
    selenium.open("/");
    selenium.windowMaximize();
    selenium.windowFocus();

    System.out.println("----------Generating window names from first window-----------");
    String winnames[] = selenium.getAllWindowNames();

    for (int i = 0; i < winnames.length; i++) {

      System.out.println(winnames[i]);
    }

    selenium.click("//*[@id='loginsubmit']");

    System.out.println("----------Generating window names from second window-----------");

    winnames = selenium.getAllWindowNames();

    for (int i = 0; i < winnames.length; i++) {

      System.out.println(winnames[i]);
    }

    selenium.selectWindow(winnames[1]);
    selenium.waitForPopUp(winnames[1], "50000");

    selenium.click("//*[@id='wrapper']/div[2]/div[2]/ul/li[1]/a");

    System.out.println("----------Generating window names from second window-----------");

    winnames = selenium.getAllWindowNames();

    for (int i = 0; i < winnames.length; i++) {

      System.out.println(winnames[i]);
    }

    selenium.selectWindow(winnames[2]);
    selenium.waitForPopUp(winnames[2], "50000");

    selenium.type(
        "//html/body/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[2]/td/form/table[2]/tbody/tr[5]/td[2]/input",
        "Raman");

    selenium.close();
    selenium.selectWindow(winnames[1]);
    selenium.close();
  }
Beispiel #3
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    String serverHost = "localhost";
    int serverPort = 4444;
    String browserStartCommand = "*chrome";
    String browserURL = "http://localhost:3000/";

    defaultSelenium = new DefaultSelenium(serverHost, serverPort, browserStartCommand, browserURL);
    defaultSelenium.start();
    defaultSelenium.open("");
    defaultSelenium.windowMaximize();
  }
  @Test
  public void should_login_with_valid_credentials() {
    browser.open(deploymentUrl.toString().replaceFirst("/$", "") + "/login.jsf");

    browser.type("id=loginForm:username", "user1");
    browser.type("id=loginForm:password", "demo");
    browser.click("id=loginForm:login");
    browser.waitForPageToLoad("15000");

    Assert.assertTrue(
        "User should be logged in!",
        browser.isElementPresent("xpath=//li[contains(text(),'Welcome')]"));
  }
Beispiel #5
0
 public static void openUrl(DefaultSelenium sClient, String url) {
   sClient.open(url);
 }
 @Test
 public void testForNews() {
   selenium.open("/index.html");
   assertTrue(selenium.isTextPresent("More News"));
 }
  @Test
  public void testTuiBao_XJ() throws Exception {
    selenium.open("/");
    selenium.click("lra24");
    selenium.waitForPageToLoad("30000");
    selenium.type("username", "api-xiejie");
    selenium.type("input2", "654321");
    selenium.click("loginBut");
    // 前台投保获得订单号
    String orderID;
    Ins_Front inf = new Ins_Front();
    orderID = inf.buy_YJX(selenium, "华泰“安达天下”国际旅游保险成人计划标准款", 8257, 1);

    selenium.type("payPwd", "65432100");
    selenium.click("subAcc");
    selenium.waitForPageToLoad("30000");
    // 调用数据库,根据订单号获得投保单号
    /*String u = "192.168.1.217";
    Connection conn = DBManager.getConnection(u);*/
    CommSql sql = new CommSql();
    // AppDTO[] app=sql.getAppInfo(conn,orderID,"");
    AppDTO[] app = sql.getAppInfo(orderID);
    String AppID;
    AppID = app[0].getAppId();
    Thread.sleep(30000);
    // 在新窗口中打开后台
    String url = "http://cst.xyz.cn";
    String win = "window";
    selenium.openWindow(url, win);
    selenium.waitForPopUp("window", "30000");
    selenium.selectWindow("window");

    selenium.type("textfield2", "xiejie");
    selenium.type("textfield", "654321");
    selenium.click("//button[@type='submit']");
    selenium.waitForPageToLoad("30000");
    selenium.click("link=保单管理");
    selenium.waitForPageToLoad("30000");
    selenium.type("APP_ID", AppID);
    selenium.click("searchBtn");
    selenium.waitForPageToLoad("30000");

    selenium.click("link=退保登记");
    selenium.waitForPageToLoad("30000");
    selenium.type("policySurrenderDto.applyReason", "12345");
    selenium.type("policySurrenderDto.applyName", "谢洁");
    selenium.type("policySurrenderDto.applyTel", "86509906");
    selenium.select("idtype", "label=军官证");
    selenium.click("//option[@value='armcard']");
    selenium.type("policySurrenderDto.cardNo", "123");
    selenium.click("surrenderCheck");
    // 上传文件
    Thread.sleep(10000);
    String baseRoot = System.getProperty("user.dir");
    String CancelINSAffixUp = null;
    Properties p = new Properties();
    InputStream in = new FileInputStream(new File("src/test/resources/instest-sys.properties"));
    p.load(in);
    CancelINSAffixUp = baseRoot + p.getProperty("CancelINSAffixUp");
    Runtime.getRuntime().exec(CancelINSAffixUp);
    // Runtime.getRuntime().exec("D:\\ins-seleniumTest\\src\\test\\resources\\AutoIt\\CancelINSAffixUp.exe");
    Thread.sleep(15000);
    selenium.click("link=上传");
    Thread.sleep(15000);

    selenium.click("//button[@type='submit']");
    Thread.sleep(15000);
    // 查询数据库,获取保单ID
    // AppDTO policy=sql.getPolicyInfo(conn,AppID);
    PolicyDTO policy = sql.getPolicyInfo(AppID);
    String policyID;
    policyID = policy.getPolicyNo();
    Thread.sleep(30000);
    // 开始退保
    selenium.type("POLICY_NO", policyID);
    selenium.click("searchBtn");
    selenium.waitForPageToLoad("30000");
    selenium.click("link=处理");
    selenium.waitForPageToLoad("30000");
    selenium.click("surrenderCheck");
    selenium.click("toAudit");
    selenium.waitForPageToLoad("30000");
    selenium.type("POLICY_NO", policyID);
    selenium.click("link=审核");
    selenium.waitForPageToLoad("30000");
    selenium.click("surrenderCheck");
    selenium.click("//input[@name=\"policySurrenderDto.surrenderStatus\"][1]");
    selenium.click("//button[@type='submit']");

    // 查询保单状态
    Thread.sleep(30000);
    // AppDTO policy1=sql.getPolicyInfo(conn,AppID);
    PolicyDTO policy1 = sql.getPolicyInfo(AppID);
    int policyStatus = policy1.getPolicyStatus();
    if (policyStatus == 2) {
      System.out.print("退保成功");
    } else {
      System.out.print("退保未成功");
    }
  }
Beispiel #8
0
  @Override
  public void open(String url) {
    if (_openonce) _cyclecount++;

    super.open(url);
  }