[OneTimeSetUp] // вызывается перед началом запуска всех тестов public void OpenWindow() { DriverSession.OpenDriver(); IWebDriver driver = DriverSession.GetDriver(); driver.Url = "https://yandex.ru"; }
public void DriverSessionExists() { Logger.Information($"Here I am"); DriverSession.Should().NotBeNull(because: "the DriverSession is instantiated in the Base Class. "); Logger.Information($"Here I am again"); DriverSession.TestCaseReporter.Name.Should().Be(TestContext.TestName, because: "the test case should have been initialized. "); }
/// <summary> /// Initializes a new instance of the <see cref="WebDriverCommandHandler"/> class. /// </summary> /// <param name="locatorParameters">A <see cref="Dictionary{K, V}"/> containing the parameters used to match a resource in the URL.</param> /// <param name="parameters">A <see cref="Dictionary{K, V}"/> containing the parameters used to operate on the resource.</param> protected WebDriverCommandHandler(Dictionary<string, string> locatorParameters, Dictionary<string, object> parameters) : base(locatorParameters, parameters) { if (!locatorParameters.ContainsKey(CommandHandler.SessionIdParameterName)) { throw new InvalidCommandException("Command requires a session ID"); } string sessionIdValue = locatorParameters[CommandHandler.SessionIdParameterName]; this.SessionId = new SessionId(sessionIdValue); this.currentSession = SessionManager.Instance.GetSession(this.SessionId); if (this.currentSession == null) { throw new ResourceNotFoundException("Could not find active session with id '" + SessionId.ToString() + "'"); } }
/// <summary> /// Initializes a new instance of the <see cref="WebDriverCommandHandler"/> class. /// </summary> /// <param name="locatorParameters">A <see cref="Dictionary{K, V}"/> containing the parameters used to match a resource in the URL.</param> /// <param name="parameters">A <see cref="Dictionary{K, V}"/> containing the parameters used to operate on the resource.</param> protected WebDriverCommandHandler(Dictionary <string, string> locatorParameters, Dictionary <string, object> parameters) : base(locatorParameters, parameters) { if (!locatorParameters.ContainsKey(CommandHandler.SessionIdParameterName)) { throw new InvalidCommandException("Command requires a session ID"); } string sessionIdValue = locatorParameters[CommandHandler.SessionIdParameterName]; this.SessionId = new SessionId(sessionIdValue); this.currentSession = SessionManager.Instance.GetSession(this.SessionId); if (this.currentSession == null) { throw new ResourceNotFoundException("Could not find active session with id '" + SessionId.ToString() + "'"); } }
public void Quit() { try { DriverSession.Driver.Close(); } catch { // ignore } try { DriverSession.Driver.SwitchTo().Alert().Accept(); DriverSession.Driver.Quit(); } catch (Exception) { DriverSession.Driver.Quit(); } DriverSession.Dispose(); }
public AbstractPage() { this.driver = DriverSession.GetDriver(); PageFactory.InitElements(driver, this); }
[OneTimeTearDown] //вызывается после завершения всех тестов public void ExitDriver() { DriverSession.CloseDriver(); }