jac*_*son 3 c# bdd google-chrome specflow selenium-webdriver
我想按照功能示例逐个执行两个测试.它工作但我不知道如何在第二次测试完成时关闭浏览器.
我已经尝试过AfterFeature钩子,但它没有用.我刚刚登录.我想在这一刻关闭浏览器
这是代码
public class LoginSteps
{
[BeforeScenario("LoginProperly")]
public static void BeforeScenario()
{
Browser.Initialize();
}
[AfterScenario("LoginProperly")]
public static void AfterScenario()
{
Browser.ClearCache();
}
[AfterFeature("LoginProperly")]
public static void AfterFeature()
{
Browser.Quit();
}
[Given(@"I navigate to login page")]
public void GivenINavigateToLoginPage()
{
Browser.Wait();
Pages.Navigation.GoToSignIn();
}
[Given(@"I have completed the form with '(.*)' and '(.*)'")]
public void GivenIHaveCompletedTheFormWithAnd(string email, string password)
{
Pages.Login.LogIn(email, password);
}
[When(@"I press Submit")]
public void WhenIPressSubmit()
{
Pages.Login.ClickLogin();
}
[Then(@"I should see my account panel")]
public void ThenIShouldSeeMyAccountPanel()
{
Pages.Account.IsAt();
}
}
}
Run Code Online (Sandbox Code Playgroud)
功能文件
Feature: Login
In order to use my account
As an application user
I want to be able to log in and log out
@LoginProperly
Scenario Outline: Login with correct Email adress and Password
Given I navigate to login page
And I have completed the form with '<email>' and '<password>'
When I press Submit
Then I should see my account panel
Examples:
| email | password |
| tescik@gmail.com | 11111 |
| tescik2@gmail.com | 22222 |
Run Code Online (Sandbox Code Playgroud)
你有没有尝试过 [AfterTestRun]
[AfterTestRun]
public static void AfterWebFeature()
{
Browser.Quit();
Brrowser.Dispose();
}
Run Code Online (Sandbox Code Playgroud)
我在IWebDriver上调用quit后总是调用dispose.
| 归档时间: |
|
| 查看次数: |
1400 次 |
| 最近记录: |