简体   繁体   English

Visual Studio 2017不在测试资源管理器中显示我的测试

[英]Visual Studio 2017 not displaying my test in the Test Explorer

I wrote the following script on my computer at work, where the script ran perfectly. 我在工作中的计算机上编写了以下脚本,该脚本可以完美运行。 However, I can't get it to run on my computer at home. 但是,我无法使其在家里的计算机上运行。 I have the exact version of Visual Studio installed. 我安装了Visual Studio的确切版本。 I click build, it successfully builds, however, it doesn't lead to the test being added to the test explorer. 我单击构建,它成功构建,但是,不会导致将测试添加到测试浏览器中。

My code is below: 我的代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using NUnit.Framework;
using OpenQA.Selenium.Support.UI;

namespace TrainLineTest
{
    public class Program 
    {
        public static IWebDriver driver = new ChromeDriver();       

        public static void Main(string[] args)
        { }

        public static void SetUp()
        {
            driver.Manage().Window.Maximize();
            driver.Url = "https://www.thetrainline.com";
        }

        [Test]
        public static void EnterDetails()
        {
            SetUp();

            var OriginStation = driver.FindElement(By.Id("originStation"));
            OriginStation.SendKeys("London Euston");

            var DestinationStation = driver.FindElement(By.Id("destinationStation"));
            DestinationStation.SendKeys("Manchester Picadilly");

            var TravelMethod = driver.FindElement(By.Id("journey-type-return"));
            TravelMethod.Click();

            var OutDate = driver.FindElement(By.Id("outDate"));
            OutDate.Clear();
            OutDate.SendKeys("26-Aug-17");
            OutDate.SendKeys(Keys.Tab);

            Thread.Sleep(700);
            new SelectElement(driver.FindElement(By.Id("outDepartOrArrive"))).SelectByValue("B");
            Thread.Sleep(700);

            new SelectElement(driver.FindElement(By.Id("outHour"))).SelectByValue("9");

            new SelectElement(driver.FindElement(By.Id("outMinute"))).SelectByValue("30");

            Thread.Sleep(700);

            var ReturnDate = driver.FindElement(By.Id("returnDate"));
            ReturnDate.Clear();
            ReturnDate.SendKeys("15-Sep-17");
            ReturnDate.SendKeys(Keys.Tab);

            Thread.Sleep(500);
            new SelectElement(driver.FindElement(By.Id("returnDepartOrArrive"))).SelectByValue("B");
            Thread.Sleep(500);

            new SelectElement(driver.FindElement(By.Id("returnHour"))).SelectByValue("14");

            new SelectElement(driver.FindElement(By.Id("returnMinute"))).SelectByValue("30");

            Thread.Sleep(500);


            var Passengers = driver.FindElement(By.ClassName("passenger-summary-people"));
            Passengers.Click();

            Thread.Sleep(500);

            new SelectElement(driver.FindElement(By.Name("AdultsTravelling"))).SelectByValue("2");

            Thread.Sleep(500);

            new SelectElement(driver.FindElement(By.Name("ChildrenTravelling"))).SelectByValue("1");

            Thread.Sleep(500);

            var JourneyComplete = driver.FindElement(By.CssSelector("#extendedSearchForm > div:nth-child(6) > div:nth-child(1) > div > div > button"));
            JourneyComplete.Click();

            Thread.Sleep(5000);

            var ExtendedSearch = driver.FindElement(By.Id("submitButton"));
            ExtendedSearch.Click();

            Thread.Sleep(5000);
        }

        [TearDown]
        public void CloseApp()
        {
            driver.Close();
        }
    }
}

If you are using NUnit3, you'll need to get NUnit3TestAdapter from the NuGet package manager. 如果您使用的是NUnit3,则需要从NuGet程序包管理器中获取NUnit3TestAdapter。 Once you have this package you'll be able to build your solution and have them show in Visual Studio's Test Explorer 拥有此软件包后,就可以构建解决方案并将其显示在Visual Studio的“测试资源管理器”中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM