I am new to C# and Selenium and I have pretty much made a number of scripts but there comes a problem when I make more than 1 method or more than 1 class single method and single class always runs good.
I have tried every possible solution on the internet and my self tried solution in which I made a new project and copied the main code other than class name, method name and namespace and pasted it onto new project it worked fine this is the same issue but I want to know what the problem really is.
These are the Four Classes:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SignUpPageAssignment
{
public class SignUpDetails
{
public static string registerPageReDirect = "login_register";
public static string signUpUserNameID = "username";
public static string signUpPasswordID = "password";
public static string confirmPasswordID = "re_password";
public static string fullNameID = "full_name";
public static string signUpEmailID = "email_add";
public static string signUpUserName = "TouqeerABCDEFGHI";
public static string signUpPassword = "Password@123";
public static string confirmPassword = "Password@123";
public static string fullName = "Touqeer Saleem";
public static string email = "[email protected]";
public static string checkBox = "tnc_box";
public static string captchaForm = "captcha-form";
public static string signUpButton = "Submit";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SignUpPageAssignment
{
public class LoginDetails
{
public static string loginUserNameID = "username";
public static string loginPasswordID = "password";
public static string loginUserName = SignUpDetails.signUpUserName;
public static string loginPassword = SignUpDetails.signUpPassword;
public static string loginButton = "login";
public static string redirectToLogin = "Click here to login";
}
}
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace SignUpPageAssignment
{
class Automation
{
public void TestMethod1()
{
IWebDriver driver = new ChromeDriver();
driver.Url = "http://adactin.com/HotelApp/";
// SIGN UP START
driver.FindElement(By.ClassName(SignUpDetails.registerPageReDirect)).Click();
driver.FindElement(By.Id(SignUpDetails.signUpUserNameID)).SendKeys(SignUpDetails.signUpUserName);
driver.FindElement(By.Id(SignUpDetails.signUpPasswordID)).SendKeys(SignUpDetails.signUpPassword);
driver.FindElement(By.Id(SignUpDetails.confirmPasswordID)).SendKeys(SignUpDetails.confirmPassword);
driver.FindElement(By.Id(SignUpDetails.fullNameID)).SendKeys(SignUpDetails.fullName);
driver.FindElement(By.Id(SignUpDetails.signUpEmailID)).SendKeys(SignUpDetails.email);
driver.FindElement(By.Id(SignUpDetails.checkBox)).Click();
driver.FindElement(By.Id(SignUpDetails.captchaForm)).SendKeys("");
Thread.Sleep(5000);
driver.FindElement(By.Id(SignUpDetails.signUpButton)).Click();
//SIGN UP END
//LOGIN IN START
driver.FindElement(By.LinkText(LoginDetails.redirectToLogin)).Click();
driver.FindElement(By.Id(LoginDetails.loginUserNameID)).SendKeys(LoginDetails.loginUserName);
driver.FindElement(By.Id(LoginDetails.loginPasswordID)).SendKeys(LoginDetails.loginPassword);
driver.FindElement(By.Id(LoginDetails.loginButton)).Click();
//LOGIN IN STOP
//IWebElement result = driver.FindElement(By.ClassName("reg_success"));
//Assert.Equals("reg_success", result);
}
}
}
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace SignUpPageAssignment
{
[TestClass]
public class UnitTest1
{
public static void Main(String[] args)
{
Automation automation = new Automation();
automation.TestMethod1();
}
}
}
I am making a signup automation script that signups and after signup it logins
The error that is displayed is :
[12/28/2018 10:44:11 PM Informational] Executing test method 'SignUpPageAssignment.UnitTest1.Main'
[12/28/2018 10:44:11 PM Informational] Executing test method 'SignUpPageAssignment.UnitTest1.Main'
[12/28/2018 10:44:11 PM Informational] ------ Run test started ------
[12/28/2018 10:44:14 PM Warning] No test matches the given testcase filter `FullyQualifiedName=SignUpPageAssignment.UnitTest1.Main` in C:\Users\touqeer\source\repos\SignUpPageAssignment\SignUpPageAssignment\bin\Debug\SignUpPageAssignment.dll
[12/28/2018 10:44:14 PM Informational] ========== Run test finished: 0 run (0:00:03.6212841) ==========
Have resolved issue with "No test matches the given testcase filter FullyQualifiedName" by running updates to latest version for next packages:
Microsoft.NET.Test.Sdk MSTest.TestAdapter MSTest.TestFramework
For NUnit test project:
NUnit3TestAdapter
My case is - an old project with NUnit 2.5 opened in a new VS2019 gives the same error.
As NUnit 2.x does not included into VS2019 by default - you need to install it.
Go to Menu -> Extensions -> ManageExtensions
then search for "NUnit 2 Test Adapter"
then install it.
That helped me.
You don't use a Main
method to run a test.
Instead, put a [TestMethod]
annotation on the methods you want to run as tests. The test runner will take care of creating an instance of your test class and calling these methods.
Methods with the [TestMethod]
annotation must be public
and void
, must not be static
and should take no arguments. Even if you put [TestMethod]
on your Main
method, the test would likely not run.
Here's what your UnitTest1
class should look like:
namespace SignUpPageAssignment
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
Automation automation = new Automation();
automation.TestMethod1();
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With