2017-09-28 4 views
1

2つのシナリオがある機能ファイルがあります。最初の反復の後、これらのシナリオをもう一度実行します。キュウリで何度もシナリオを実行する方法

追加する必要があるものは何ですか?ステップ定義ファイルに同じJavaコードをコピーする必要がありますか、それとも別の方法がありますか?

フィーチャーファイル::

@sanity 
Feature: To test Proscape Smoke Test 

Scenario: To launch the Proscape Application Mockup URL 
Given Open the chrome and launch the application 
When user enter url 
And click on Test Project 
And user clicks on Parameter button of Details page 
Then Details Page should display 

Scenario Outline: Details page display 
Given Details page is diplayed 
When user enter value in first Fixture Type "<FF1>" 
And user enter second Fixture Type "<FF2>" 
And user enter third Fixture Type "<FF3>" 
And user clicks on Next button 
Then Category Page should display 

Examples:  
| FF1 | FF2 | FF3 | 
| a | b | c | 

StepDefinition:あなたはより多くのシナリオのを実行したい場合は

@Given("^Open the chrome and launch the application$") 
    public void open_the_chrome_and_launch_the_application() throws Exception { 
     System. setProperty("webdriver.chrome.driver", "C:\\Mohini\\AutomationStart\\chromedriver.exe"); 
     driver= new ChromeDriver() ; 
     driver.manage().window().maximize(); 
    } 


@When("^user enter url$") 
    public void user_enter_url() throws Exception { 
     driver.get("http://t53umx.axshare.com/#g=1&p=home"); 
     driver.findElement(By.id("Password")).sendKeys("landg"); 
     Thread.sleep(5000); 
     driver.findElement(By.className("loginsubmit")).click(); 
     driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);  
    } 

@When("^click on Test Project$") 
    public void click_on_Test_Project() throws Exception { 
     driver.switchTo().frame("mainFrame"); // use this if it's in frame and you don't know how to locate it 
     WebElement element = (new WebDriverWait(driver, 100)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='u133_img']"))); 

     Actions action = new Actions(driver); 

     action.moveToElement(element).click(); 
     Thread.sleep(5000); 
     //element.click(); 
     action.perform(); 
     driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);  
    } 

@When("^user clicks on Parameter button of Details page$") 
    public void user_clicks_on_Parameter_button_of_Details_page() throws Exception { 
     //driver.findElement(By.id("u47_div")).click(); 
     try { 
      WebDriverWait wdw = new WebDriverWait(driver, 50); 
      long startTime = System.currentTimeMillis(); 
      long endTime = System.currentTimeMillis(); 
      long pageLoadTime = (endTime - startTime); 
      WebElement element = wdw.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='u47']"))); //we will not use div here in id 

      Actions action = new Actions(driver); 
      action.moveToElement(element).build().perform(); 
      Thread.sleep(5000); 
      element.click(); 

      System.out.println(pageLoadTime); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 

@Then("^Details Page should display$") 
    public void details_Page_should_display() throws Exception { 
     Thread.sleep(5000);  
    } 

@Given("^Details page is diplayed$") 
    public void details_page_is_diplayed() throws Exception { 

    } 

@When("^user enter value in first Fixture Type \"([^\"]*)\"$") 
    public void user_enter_value_in_first_Fixture_Type(String arg1) throws Exception { 
     WebDriverWait wdw1 = new WebDriverWait(driver, 50); 
     WebElement element1 = wdw1.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='u68_input']"))); //we will not use div here in id 
     System.out.println("Ff1 = "+arg1); 
     element1.sendKeys(arg1); 
    } 

@When("^user enter second Fixture Type \"([^\"]*)\"$") 
    public void user_enter_second_Fixture_Type(String arg1) throws Exception { 
     System.out.println("Ff2 = "+arg1); 
     driver.findElement(By.xpath("//*[@id='u70_input']")).sendKeys(arg1); 
     Thread.sleep(2000); 
    } 

@When("^user enter third Fixture Type \"([^\"]*)\"$") 
    public void user_enter_third_Fixture_Type(String arg1) throws Exception { 
     System.out.println("Ff3 = "+arg1); 
     driver.findElement(By.xpath("//*[@id='u71_input']")).sendKeys(arg1); 
     Thread.sleep(2000); 
    } 

@When("^user clicks on Next button$") 
    public void user_clicks_on_Next_button() throws Exception { 
     Select fixturetype= new Select(driver.findElement(By.xpath("//*[@id=\"u85_input\"]"))); 
     fixturetype.selectByVisibleText("LED"); 
     Select lamp= new Select(driver.findElement(By.xpath("//*[@id=\"u84_input\"]"))); 
     lamp.selectByVisibleText("1000W"); 
     driver.findElement(By.xpath("//*[@id=\"u82_text\"]")).click(); 
     Thread.sleep(2000); 
     driver.findElement(By.xpath("//*[@id=\"u89_text\"]")).click(); 
     Thread.sleep(2000); 
    } 

@Then("^Category Page should display$") 
    public void category_Page_should_display() throws Exception { 
     //driver.switchTo().frame("mainFrame"); 
     WebDriverWait wdw = new WebDriverWait(driver, 300); 
     WebElement element = wdw.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='u1041']"))); 
     element.click(); 
     Thread.sleep(5000); 
     driver.findElement(By.xpath("//*[@id='u1197']")).click(); 
     Thread.sleep(5000); 
     driver.findElement(By.xpath("//*[@id='u1117']")).click(); 
     Thread.sleep(5000); 
     driver.findElement(By.xpath("//*[@id=\"u1113\"]")).click(); 
     Thread.sleep(2000); 
     driver.findElement(By.xpath("//*[@id=\"u1137\"]")).click(); 
     Thread.sleep(2000); 
     driver.findElement(By.xpath("//*[@id=\"u1215\"]")).click(); 
     Thread.sleep(2000); 
     driver.findElement(By.xpath("//*[@id=\"u1138\"]")).click(); 
     Thread.sleep(2000); 
     driver.findElement(By.xpath("//*[@id=\"u1114\"]")).click(); 
     Thread.sleep(2000); 
    } 
} 

答えて

0

、あなたの機能ファイルにそれらを追加することができます。 異なる例のシナリオのアウトラインを使用すると、テストケースを追加するのが非常に簡単です。 あなたは、例えば、テーブル内の別の行を追加することによって、別の例を追加することができます:あなたが最初のシナリオは、(中断したところから2番目のシナリオ(シナリオ概要)を実行するように

Examples:  
| FF1 | FF2 | FF3 | 
| a | b | c | 
| d | e | f | 

をあなたの例から、それはそうですすなわち、あなたが詳細ページにいたら)。

最初のシナリオは、2番目のシナリオのためにのみ設定(またはシナリオが概説)、あなたがそうのように、それらを一緒にマージする必要がありの場合:

ユーザーを考えるとここで
@sanity 
Feature: Proscape Smoke Test 

Scenario Outline: Details page display 
Given the user opens the details page of the Test Project 
When user enter value in first Fixture Type "<FF1>" 
And user enter second Fixture Type "<FF2>" 
And user enter third Fixture Type "<FF3>" 
And user clicks on Next button 
Then Category Page should display 

Examples:  
| FF1 | FF2 | FF3 | 
| a | b | c | 
| d | e | f | 

は、」テストの詳細ページを開きます前の手順(アプリケーションのURLを開き、詳細ページにナビゲート)として「プロジェクト」を実装する必要があります。

関連する問題