2016-11-16 6 views
-1

私は基本的なキュウリ試験をSelenium integratedと書いています。サイトのログイン情報を開いてログインしているかどうかを確認したいのですが、テストの最初のステップに問題があります。試験は無期限に実行されます。 Here you can see my map structure all the other maps are emptyセレンのみを開いてブラウザを直接閉じる

import cucumber.api.junit.Cucumber; 
import org.junit.runner.RunWith; 

@RunWith(Cucumber.class) 
public class CucumberRunner { 
} 

これは私のランナークラスです

Feature: To If i can login 

    Scenario: Check if login is complete 
    Given I am on the website 
    When I click on login 
    And Populate the contact form 
    Then I should be on the account page 

これは私の機能

import cucumber.api.java.en.And; 
import cucumber.api.java.en.Given; 
import cucumber.api.java.en.Then; 
import cucumber.api.java.en.When; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import static junit.framework.TestCase.assertTrue; 


public class StepDefinitions { 

    private WebDriver driver; 

    @Given("^I am on the website$") 
    public void ShouldnavigateToWebsite(){ 
     System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe"); 
     System.out.println("voor"); 
     driver = new FirefoxDriver(); 
     System.out.println("na"); 
     driver.get("http://www.store.demoqa.com"); 
    } 


    @When("^I click on login$") 
    public void ClickOnLink(){ 
     driver.findElement(By.id("account")).click(); 
    } 

    @And("^Populate the contact form$") 
    public void PopulateForms(){ 
     driver.findElement(By.id("log")).sendKeys("TimoTest"); 
     driver.findElement(By.id("pwd")).sendKeys("TimoTest1"); 
     driver.findElement(By.id("login")).click(); 
    } 

    @Then("^I should be on the account page$") 
    public void ShouldBeOnContactPage(){ 
     assertTrue("Not one account page",driver.getTitle().equals("your-account")); 
    } 
} 

であり、ここでテストそのものです。 彼がプリントする唯一のものはvoor(Before)です。

+0

実行中のマシンにコードがコメントされていますか? – Moshisho

+0

前にコメントをつけたコードを実行し、それが役に立ったかどうかをコメントしました。それは実行されないので、譲渡人のドライバを通過することはありません – Nick

+0

したがって、 "" na "は印刷されませんか?そしてFirefoxはすぐに開いたり閉じたりしますか? – Moshisho

答えて

0

私はあなたの問題がバージョンにあると信じています。 FirefoxがSeleniumを使わずに開くと、更新が保留中でないことがわかります。存在する場合は、最新バージョンに更新してください。そして、最新のselenium-javaが3.0.1であることを確認してください。それがあなたの問題を解決することを願っています。

関連する問題