ユーザーがホテル予約プラットフォーム&にログインできることを確認するためのコードを記述しました。確認手順も追加しました。 Assert.IsTrue()
メソッドでエラー が表示されます。他のすべてのものはコード内で問題ありません。エラー:名前アサートが現在のコンテキストに存在しない
私は可能な解決策についていくつかの調査を行いました。ここで
は、私はStackOverflowの上で見つかったソリューションです:Assert Method Error
私は私のプロジェクト参照にMicrosoft.VisualStudio.QualityTools.UnitTestFrameworkを追加してもMicrosoft.VisualStudio.TestTools.UnitTestingを使用して
を追加しました。 & NUnit.Frameworkを使用します。コードの私の使用セクションに移動します。
は、私は次のエラーを取得:
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
私はバインディングを削除した後、同じエラーが出る - Microsoft.VisualStudio.TestTools.UnitTesting。 & NUnit.Frameworkを使用しています。
そして、最終的にここのコードは次のとおりです。
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.");
}
}
}
はあなたの助けをいただき、ありがとうございます。
ありがとう – OA345