黄瓜特征文件不使用Maven执行 [英] Cucumber feature files are not executed using Maven

查看:159
本文介绍了黄瓜特征文件不使用Maven执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在eclipse中使用Maven设置了一个Java项目。



每当我试图运行脚本时,我面临一个问题。



请看看下面的代码和我的目录设置在eclipse中的图像





以下是我的代码:PageStepsDefs.java

 机场。 

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;

public class PageStepsDefs {

public String ChromeDriverPath =C:\\Users\\zain.jamshaid\\Desktop\\chromedriver。可执行程序;
public WebDriver驱动程序;
String localhost =www.google.com;

@Before
public void deleteAllCookies(){
driver.manage()。deleteAllCookies();
driver.manage()。window()。maximize();
}

@Before
public void setup(){
System.setProperty(webdriver.chrome.driver,ChromeDriverPath);
driver = new ChromeDriver();
}

@Given(^我要浏览到(。+)页面$)
public void open_page(String url)
{

driver.get(localhost + url);
System.out.println(localhost + url);
}

@After
public void tearDown(){
driver.quit();
}
}

这里是我的代码RunCukeTest.java

  package com.workshop.airport.workshop.airport; 

import cucumber.api.junit。*;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@ Cucumber.Options(
tags = {@ mysingle},
format = {pretty,html :target / cucumber-html-report},
monochrome = true,
features = {。},
strict = true)

public class RunCukeTest {

}

strong>

 功能:登录功能
@mysingle
方案:用户成功登录应用程序

如果我浏览到/ page

任何帮助将是真棒。 p>

感谢提前。
Zain

解决方案

我想我知道这个问题。根据你的评论,'/'从功能文件被正确解析到你的步骤。所以这不是一个黄瓜问题。我认为是你的url的问题。您的网址格式不正确。 URL应该以 http://



开头我认为如果你将localhost变量更改为 String localhost =http://www.google.com;


Hi I have setUp a Java project using Maven in eclipse.

I am facing an issue whenever I am trying to run the script. Its is executed by the not opening the desired website which I am parsing from the feature file.

Please have a look to the following code and Image of my directories setup in eclipse

Here is my code for PageStepsDefs.java

package com.workshop.airport.workshop.airport;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;

public class PageStepsDefs {

    public String ChromeDriverPath="C:\\Users\\zain.jamshaid\\Desktop\\chromedriver.exe";
    public WebDriver driver;
    String localhost="www.google.com";

    @Before
    public void deleteAllCookies() {
        driver.manage().deleteAllCookies();
        driver.manage().window().maximize();
    }

    @Before
    public void setup(){
        System.setProperty("webdriver.chrome.driver",ChromeDriverPath);
        driver = new ChromeDriver();    
    }

    @Given("^I browse to the (.+) page$")
    public void open_page(String url)
    {

        driver.get(localhost+url);
        System.out.println(localhost+url);
    }

    @After
    public void tearDown(){
        driver.quit();
    }
}

Here is my code for RunCukeTest.java

package com.workshop.airport.workshop.airport;

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

@RunWith(Cucumber.class)
@Cucumber.Options(
        tags={"@mysingle"},
        format={"pretty", "html:target/cucumber-html-report"},
        monochrome=true,
        features={"."}, 
        strict=true)

public class RunCukeTest {

}

Here is statements in feature file

Feature: Login Functionality
@mysingle
Scenario: user successfully logins to the application

    Given I browse to the / page

Any help will be awesome.

Thanks In advance. Zain

解决方案

I think I know the problem. As per your comment, the '/' from feature file is getting parsed to your step correctly. So this is not a cucumber issue. The issue I think is with your url. The url you have is incorrectly formed. URL should start with http://

I think everything will work fine if you change your localhost variable to String localhost="http://www.google.com";

这篇关于黄瓜特征文件不使用Maven执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆