获取java.lang.IllegalArgumentException:Selenium驱动程序脚本中的参数数量错误

时间:2015-10-19 13:18:35

标签: java selenium selenium-webdriver

我正在研究Selenium Keyword framework.Below是我的代码片段。我的脚本工作正常,但我不明白为什么会出现此错误请帮我解决此异常。

主要课程

public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{                
   HttpResponseHeaders headers = actionExecutedContext.Response.Headers;
   IEnumerable<string> values;
   if (headers.TryGetValues("Set-Cookie", out values))
   {
       actionExecutedContext.Response.Headers.Remove("Set-Cookie");
   }

   base.OnActionExecuted(actionExecutedContext);
}

操作关键字类

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

        ExcelUtils.setExcelFile(Cls_constant.testDataPath,
                Cls_constant.testDataFile, "Sheet1");
        // int rowCount =
        // ExcelUtils.worksheet.getLastRowNum()-ExcelUtils.worksheet.getFirstRowNum();

        for (int irow = 1; irow <= 6; irow++) {

            sActionKeyword = ExcelUtils.getCellData(irow, 3);
            execute_Actions();

        }
    }

    public static void execute_Actions() {
        try {
            ActionKeywords actionKeywords = new ActionKeywords();
            method = actionKeywords.getClass().getMethods();

            // System.out.println(method);
            for (int i = 0; i < method.length; i++) {
                if (method[i].getName().equalsIgnoreCase(sActionKeyword)) {
                    // method[i].invoke(actionKeywords,param );
                    method[i].invoke(actionKeywords);
                    // System.out.println("Im in for loop");
                    break;
                }
            }
        } catch (InvocationTargetException e) {
            e.getCause().printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();

        }

    }

}

例外的StackTrace

 public class ActionKeywords {
    public static WebDriver driver = null;

    public static void open_browser() {
        driver = new FirefoxDriver();
    }

    public static void navigate() {
        driver.get("https://qa-survey.greatplacet.com/");
    }

    public static void set_uname() {
        driver.findElement(By.id("inputEmail")).sendKeys("primary@gmail.com");

    }

    public static void set_passwd() {
        driver.findElement(By.id("inputPassword")).sendKeys("Ch#s3crum8");
    }

    public static void click_login() {
        driver.findElement(By.xpath(".//*[@id='loginform']/button")).click();
    }

0 个答案:

没有答案