Cucumber feature files are not executed using Maven(不使用 Maven 执行黄瓜功能文件)
问题描述
您好,我在 Eclipse 中使用 Maven 设置了一个 Java 项目.
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.
请查看以下代码和我在 eclipse 中设置的目录的图像
Please have a look to the following code and Image of my directories setup in eclipse
这是我的 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();
}
}
这是我的 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 {
}
这是功能文件中的声明
Feature: Login Functionality
@mysingle
Scenario: user successfully logins to the application
Given I browse to the / page
任何帮助都会很棒.
提前致谢.扎因
推荐答案
我想我知道问题所在.根据您的评论,功能文件中的/"正在正确解析为您的步骤.所以这不是黄瓜的问题.我认为问题在于您的网址.您拥有的网址格式不正确.URL 应以 http://
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://
我认为如果您将 localhost 变量更改为 String localhost="http://www.google.com";
I think everything will work fine if you change your localhost variable to String localhost="http://www.google.com";
这篇关于不使用 Maven 执行黄瓜功能文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:不使用 Maven 执行黄瓜功能文件


- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 获取数字的最后一位 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 转换 ldap 日期 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01