【问题标题】:Examples are not executing in Cucumber,Web Page is not Initiated示例未在 Cucumber 中执行,网页未启动
【发布时间】:2020-11-16 22:26:41
【问题描述】:
public class Login_Applicant_StepDef {
  
    WebDriver driver;
    
    @Given("^the URL$")
    public void the_URL() throws Throwable {
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\SSMP\\Downloads\\chromedriver_win32\\ChromeDriver.exe");
        driver = new ChromeDriver();
        
        driver.get("http://localhost:4200/app-home");
    }
    
    @When("^Click on the Applicant Click here button$")
    public void click_on_the_Applicant_Click_here_button() {
        driver.findElement(By.xpath("//a[contains(text(),'Candidate click here')]")).click();;
        //JavascriptExecutor jvs= (JavascriptExecutor)driver;
        //jvs.executeScript("argumnets[0].click()",emailBtn);
    }

    @Then("^user will navigate to login Page$")
    public void user_will_navigate_to_login_Page()  {
        
        driver.navigate().to("http://localhost:4200/candidate");
    }
    
    @Then("^enter valid \"([^\"]*)\"$")
    public void enter_valid_email(String email)  {
        driver.findElement(By.xpath("//input[@id='mat-input-0']")).sendKeys(email);
    }
    
    @Then("^click on Submit button$")
    public void click_on_Submit_button()  {
    driver.findElement(By.xpath("//span[@class='mat-button-wrapper']")).click();
    //JavascriptExecutor js= (JavascriptExecutor)driver;
    //js.executeScript("argumnets[0]..click()",loginBtn);
}
}

我创建了两个功能文件和步骤定义,现在有 1 个功能文件和步骤定义链接到 TestRunner。如何将多个 FF 和 Stepdef 链接到测试运行器 另外,尽管我添加了示例,但程序没有运行

Applicant login

Test Runner

@App_login
Feature: Optevus Applicant Login Feature 

Scenario Outline: login with valid Credentials 
    Given the URL 
    When Click on the Applicant Click here button 
    Then user will navigate to login Page 
    Then enter valid "<email>"
    Then click on Submit button
    
Examples:
    | email                 |
    | kallursh@gmail.com    |
    | kallurishar@gmail.com |    

【问题讨论】:

  • 请用代码替换截图。

标签: java selenium cucumber bdd gherkin


【解决方案1】:

您没有说明您使用哪种语言,但我假设是 Java。我已经回答了一些关于这个herehere 的问题。这应该可以帮助您处理多个功能文件。我不确定您是否可以拥有多个胶水文件/步骤定义。但是您可以使用您的步骤定义来调用其他类文件中的方法。

【讨论】:

  • 硒,带 ava
【解决方案2】:

在@CucumberOptions 中,在feature 选项中提供特征文件所在的文件夹路径,在glue 选项中提供stepdef 文件夹路径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多