Test execution not running with Nunit, Selenium and C#

I am trying to learn and setup NUnit with Selenium in C#. Following are included in my framework

  • Visual Studio Community 2017
  • Nunit 3 Test Adapter, Ver 3.9.0.0
  • Nunit v3.9.0
  • Selenium Webdriver 3.7.0
  • Selenium Webdriver IEDriver v3.7.0
  • When I run my code nothing happens the test explorer does not show any execution. I am unable to resolve this.

    Check video for the issue https://screencast-o-matic.com/watch/cbX3rQ2t6Z

    Below is the code

        using NUnit.Framework;
        using OpenQA.Selenium;
        using OpenQA.Selenium.IE;
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
    
        namespace TestTut
        {
    
        class Program
        {
    
        //Declaring IE driver
        IWebDriver driver = new InternetExplorerDriver();
    
        static void Main(string[] args)
        {
        }
    
        [SetUp]
        public void Initialize()
        {
            //Navigate to test URL
            driver.Navigate().GoToUrl("http://www.google.com/");
        }
    
        [Test]
        public void ExecuteTest()
        {
    
            //Enter in Google search
            IWebElement element = driver.FindElement(By.Name("q"));
    
            //perform action
            element.SendKeys("This is a test");
            Console.WriteLine("Type the text in search box");
        }
    
        [TearDown]
        public void CloseDriver()
        {
            //Close the browser
            driver.Close();
    
        }
        }
        }
    

    Hmm... maybe I'm wrong on this but shouldn't you start running it as a unit test from test explorer or whatever its name is?

    The problem might be that you're running it as a console application and since your Main method is empty it of course doesn't do anything.

    链接地址: http://www.djcxy.com/p/63424.html

    上一篇: SQLAlchemy版本控制关注类导入顺序

    下一篇: 测试执行不与Nunit,Selenium和C#一起运行