使用Selenium RC,Excel(数据驱动)和SeleniumException

我现在正在开发一个自动化项目,在特定的网站上创build一个帐户。 有不同的规则需要检查。 需要有一组数据,其中缺less一些必填字段,用于在帐户上创build的电子邮件地址已经在系统上使用,最后一组是可以创build帐户的地方。 该过程的一般stream程是:

  1. 运行SeleniumRC
  2. 从ExcelFile获取数据

    Excel数据由不同的集合组成。 设置A:缺less所需的Fille设置B:电子邮件地址已被使用设置B:完整/正确的数据

  3. 去网站。

  4. input所有数据。

    如果设置为A:

    Then creation will not process. It will provide output: Row Number - Error 

    如果设置B:

     Then creation will not process. It will provide output: Row Number - Error 

    如果设置C:

     It will create account. 

    提供屏幕截图盎司login

  5. 返回到步骤2,直到Excel文件中find的所有行都被完全检查。

  6. 输出将被放置在另一个Excel文件中

我能够运行的过程,但是,如果我在Excel文件中的每个条目使用一个标志。 这确实破坏了检查创build过程的预期目的。 我的selenium命令是这样的:

  public void test_CreateAccount() throws Exception { //Some code to data from Excel Sheet totalrows = s.getRows(); int i = 1; while(i<totalrows){ //Some command to set data to string names RowNum = s.getCell(0, i).getContents(); FName = s.getCell(1, i).getContents(); selenium.open // Go to a specific site selenium.click("css=a > img"); // click create account selenium.waitForPageToLoad("60000"); selenium.type("name=q1557", FName); selenium.type("name=q1558", LName); selenium.type("name=q1578", JobTitle); selenium.type("name=q1579", email1); selenium.type("name=email_confirm", email2); selenium.type("name=q1583", phone); selenium.type("name=q1584", ext); selenium.type("name=q1585", fax); selenium.type("name=q1587", company); selenium.select("name=q1588", organization); selenium.type("name=q1591", address1); selenium.type("name=q1592", address2); selenium.type("name=q1593", city); selenium.select("name=q1594",state); selenium.type("name=q1595", other); selenium.type("name=q1598", zip); selenium.select("name=q1596", country); selenium.type("name=q1599", password1); selenium.type("name=password_confirm", password2); selenium.type("name=q1600", question); selenium.type("name=q1601", answer); selenium.click("name=submit_signup"); // click submit i = i + 1; } } 

当我运行上面的命令,这是行不通的。 如果数据是SET A或B,则发生错误。 如果数据是SET C,那么它将创build并完成。

为了检查Excel文件中的所有数据或继续,直到totalrows结束,我放置了一个标志。

在命令的中间,我放置了类似的东西

 if(flag=1){ //input process only until submit button. }else if(flag=2){ //input process only until submit button. }else{ create } 

我尝试使用尝试和SeleniumException但是它仍然无法正常工作。 你能告诉我如何做到这一点。