步骤定义文件错误

时间:2019-05-29 16:42:19

标签: c# specflow

我使用Specflow处理一个简单的步骤定义文件,该页面使用Nunit测试还可以。有人可以解释附件中显示的错误吗?我可以在单元测试文件中执行相同的操作。

[![错误的屏幕截图] [2]] [2]

using OpenQA.Selenium;
using System;
using OpenQA.Selenium.Chrome;
using TechTalk.SpecFlow;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TedsChallenge.step_definition
{
    [Binding]
    public class RestaurantNameSteps
    {

        private static IWebDriver driver;
        driver = new ChromeDriver();

        //public RestaurantNameSteps(IWebDriver driver)
        //{
        //    driver = new ChromeDriver();
        //    //this.driver = driver;
        //    driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);

        //}

        YelpHomepage yelpHomepage = new YelpHomepage(driver);

        [Given(@"Navigated to Yelp site")]
        public void GivenNavigatedToYelpSite()
        {

            yelpHomepage.NavigateToYelp();
        }

        [When(@"Search for a restaurant")]
        public void WhenSearchForARestaurant()
        {
            yelpHomepage.SendSearchString("Teds Montana Grill", "Denver, CO");

            //_driver.Close();
        }

        [Then(@"Display and verify the name")]
        public void ThenDisplayAndVerifyTheName()
        {
            string nameofRes = yelpHomepage.GetNameofRestuarant();
            Console.WriteLine(nameofRes);
            //Verify the name of the restaurant on the page


  [1]: https://i.stack.imgur.com/Sg2c9.png
  [2]: https://i.stack.imgur.com/otTsL.png

0 个答案:

没有答案