I have written some code to verify, that a user can login to a hotel booking platform & I also added a verification step. I get an error
on the Assert.IsTrue()
Method. Every other thing is fine in the code.
I did some research for a possible solution before stopping by.
Here is the solution I found on StackOverflow
: https://stackoverflow.com/questions/8695595/assert-method-error
I have added Microsoft.VisualStudio.QualityTools.UnitTestFramework
to my project references and also added
using Microsoft.VisualStudio.TestTools.UnitTesting; & using NUnit.Framework;
to my Using section of the code.
I get the following errors:
Severity Code Description Project File Line Suppression State Error CS0234 The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) PremierInn_Valid_User_Login c:\users\XXXX\onedrive\documents\visual studio 2015\Projects\PremierInn_Valid_User_Login\PremierInn_Valid_User_Login\Program.cs 5 Active
Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?) PremierInn_Valid_User_Login c:\users\XXXX\onedrive\documents\visual studio 2015\Projects\PremierInn_Valid_User_Login\PremierInn_Valid_User_Login\Program.cs 6 Active
I get the same error after removing the bindings -
Microsoft.VisualStudio.TestTools.UnitTesting; & using NUnit.Framework.
And, finally here is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System.Threading.Tasks;
namespace PremierInn_Valid_User_Login {
class Program {
static void Main(string[] args) {
//Instantiate Firefox Driver
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://secure.premierinn.com/en/mypremierinn/home.action");
//Enter User Name - My Email Address
var user = driver.FindElement(By.Id("loginForm.username"));
user.SendKeys("[email protected]");
//Enter Password - Account Pasword
var pass = driver.FindElement(By.Id("loginForm.password"));
pass.SendKeys("Testing123");
//Click on Login button
driver.FindElement(By.Id("loginForm.button")).Click();
var loggedInHeader = driver.FindElement(By.Id("body-inner"));
Assert.IsTrue(loggedInHeader.Displayed, "The user was able to successfully login.");
}
}
}
Any ideas?