我的最终目标是让我的老板(不是技术人员(自己使用测试软件。没有Visual Studio或任何其他第三方软件(所以,我需要构建一个用户界面。这是我的一个场景的样子。巧妙地让这个场景在控制台中运行(我稍后可以弄清楚 UI(,或者在没有 Visual Studio 的情况下完成规范流生成的 HTML 报告。 我还需要用户选择运行哪个方案。
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using System;
using System.Threading.Tasks;
using TechTalk.SpecFlow;
using static Aflutter3.Element_objects.Element;
using static Aflutter3.Element_objects;
using static Aflutter3.Other_Functions;
using static Aflutter3.Login_Class;
namespace Aflutter3
{
[Binding]
public class SigninSteps
{
[Given(@"I open google chrome")]
public void GivenIOpenGoogleChrome()
{
if (Driver != null)
Console.WriteLine("Opened");
else
Console.WriteLine("Unsuccessfully Opened");
}
[Given(@"I go to aflutter sign in page")]
public void GivenIGoToAflutterSignInPage()
{
if (Go_To_LoginPage() == true)
Console.WriteLine("Website successfully Accessed");
else
Console.WriteLine("Website unsuccessfully Accessed");
}
[Given(@"I enter the username and password")]
public void GivenIEnterTheUsernameAndPassword()
{
Enter_Credentials();
Console.WriteLine("Username and password successfully entered");
}
[When(@"i click sign in")]
public void WhenIClickSignIn()
{
Click_Sign_in();
Console.WriteLine("Login To Aflutter Button Successfully Clicked");
}
[Then(@"I should be in the homepage")]
public void ThenIShouldBeInTheHomepage()
{
if (Check_If_Homepage_Loaded())
Console.WriteLine("Homepage was succesfully loaded");
else
Console.WriteLine("Homepage was unsuccesfully loaded");
}
}
}
最好创建一个文件,它将经历所有流程 - 开始测试,生成报告,也许打开报告。它可以是cmd文件或power-shell脚本。当这个脚本被执行时,一切都发生了,你的老板只需要检查报告。