2017-11-11 3 views
0

"before"を使用してドライバインスタンスを作成し、Firefoxをキュウナフィーチャファイルで起動するにはどうすればよいですか?キュウリの前の使用方法

私はバックグラウンドに精通していますが、以前は使用されていませんでした。

+2

これは、Cucumber's @Beforeのドキュメントへのリンクを提供する以外に、私が現在のフォームで答えることができないと考える非常に広い質問です。あなたが投稿できるコードを試してみませんか?どの言語を使ってみようとしていますか? –

答えて

1

この例では、ちょうど概念を理解するためにキュウリフックのいくつかの簡単な例をやってみましょうToolsQA

から取られています。

Feature: Test Hooks 

Scenario: This scenario is to test hooks functionality 
    Given this is the first step 
    When this is the second step 
    Then this is the third step 

ステップの定義

package stepDefinition; 

import cucumber.api.java.en.Given; 
import cucumber.api.java.en.Then; 
import cucumber.api.java.en.When; 

public class Hooks_Steps { 

    @Given("^this is the first step$") 
    public void This_Is_The_First_Step(){ 
     System.out.println("This is the first step"); 
    } 

    @When("^this is the second step$") 
    public void This_Is_The_Second_Step(){ 
     System.out.println("This is the second step"); 
    } 

    @Then("^this is the third step$") 
    public void This_Is_The_Third_Step(){ 
     System.out.println("This is the third step"); 
    } 

} 

****注意***:ステップの定義に使用される何のロジックがありません。ステップサマリログを印刷するだけです。*

シナリオの場合は、ここでドライバを初期化します。

フック

package utilities; 
import cucumber.api.java.After; 
import cucumber.api.java.Before; 

public class Hooks { 

    @Before 
    public void beforeScenario(){ 
     System.out.println("This will run before the Scenario"); 
    } 

    @After 
    public void afterScenario(){ 
     System.out.println("This will run after the Scenario"); 
    } 
} 

パッケージのインポート文がインポートcucumber.api.java.Afterでなければならないことを確認してください。 & import cucumber.api.java.Before; 多くの人が間違ってJunit注釈をインポートすることがありますので、注意してください。

フックから enter image description here

Apartsのは、あなたがキュウリで他の有用なアノテーションを利用することができます出力は、ToolsQA.com here上のチュートリアルを参照してください。

関連する問題