2016-05-05 15 views
4

要素の作成ボタンをテストするための機能ファイルを作成しました。しかし、それはエラーメッセージcucumber.runtime.CucumberExceptionのエラーは何ですか:Arity mismatch:Javaでのセレンのステップ定義

cucumber.runtime.CucumberException: Arity mismatch: Step Definition. 

私は自動テストに新しいので、なぜ起こって知りません。

以下は私が書いたコードです。

@When("^create elements$") 
public void create_elements_for_attributes(WebElement elementToClick) throws Throwable { 
driver.findElement(By.id("newElement")).click(); 
} 

私が受け取ったエラーは次のとおりです。あなたがタイプWebElementの一つの引数を期待しているが、あなたの正規表現は、任意の引数をキャプチャしていない、あなたのcreate_elements_for_attributes方法で

cucumber.runtime.CucumberException: Arity mismatch: Step Definition 'mCollector.features.StepDefinitions_mCollector.create_elements_for_attributes(WebElement) in file:/C:/Users/Admin/workspace/MStudio%20-%20eBilling/bin/' with pattern [^create elements$] is declared with 1 parameters. However, the gherkin step has 0 arguments []. 
+0

以下の回答は役に立ちましたか? –

答えて

2

。あなたはキュウリ機能ファイルからWebeElementオブジェクトを渡すことができないため

When create elements "element" 

しかし、それはどちらか動作しません。

あなたのフィーチャーファイル内
@When("^create elements \"([^\"]*)\"$") 

そして:それは代わりにそのようになるはずです。プリミティブ値とDataTableで操作する必要があります。他のタイプ(WebeElement)など)は、グルーコード自体の内部に作成する必要があります。

関連する問題