private void driver_FindingElement(object sender, FindElementEventArgs e) { Common.Delay(Config.Settings.runTimeSettings.CommandDelayMs); if (Config.Settings.reportSettings.commandLogging) { TestBase.LogEvent(GetLogMessage("Finding", e)); } }
public IWebElement FindElement(By by) { IWebElement result = null; try { FindElementEventArgs e = new FindElementEventArgs(this.driver, by); this.OnFindingElement(e); IWebElement underlyingElement = this.driver.FindElement(by); this.OnFindElementCompleted(e); result = this.WrapElement(underlyingElement); } catch (Exception thrownException) { this.OnException(new WebDriverExceptionEventArgs(this.driver, thrownException)); throw; } return(result); }
public ReadOnlyCollection <IWebElement> FindElements(By by) { List <IWebElement> list = new List <IWebElement>(); try { FindElementEventArgs e = new FindElementEventArgs(this.driver, by); this.OnFindingElement(e); ReadOnlyCollection <IWebElement> readOnlyCollection = this.driver.FindElements(by); this.OnFindElementCompleted(e); foreach (IWebElement current in readOnlyCollection) { IWebElement item = this.WrapElement(current); list.Add(item); } } catch (Exception thrownException) { this.OnException(new WebDriverExceptionEventArgs(this.driver, thrownException)); throw; } return(list.AsReadOnly()); }
/// <summary> /// Raises the <see cref="FindingElement"/> event. /// </summary> /// <param name="e">A <see cref="FindElementEventArgs"/> that contains the event data.</param> protected virtual void OnFindingElement(FindElementEventArgs e) { if (this.FindingElement != null) { this.FindingElement(this, e); } }
/// <summary> /// Find all <see cref="IWebElement">IWebElements</see> within the current context /// using the given mechanism. /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns>A <see cref="ReadOnlyCollection{T}"/> of all <see cref="IWebElement">WebElements</see> /// matching the current criteria, or an empty list if nothing matches.</returns> public ReadOnlyCollection<IWebElement> FindElements(By by) { List<IWebElement> wrappedElementList = new List<IWebElement>(); FindElementEventArgs e = new FindElementEventArgs(this.driver, by); this.OnFindingElement(e); ReadOnlyCollection<IWebElement> elements = this.driver.FindElements(by); this.OnFindElementCompleted(e); foreach (IWebElement element in elements) { IWebElement wrappedElement = this.WrapElement(element); wrappedElementList.Add(wrappedElement); } return wrappedElementList.AsReadOnly(); }
/// <summary> /// Finds the first element in the page that matches the <see cref="By"/> object /// </summary> /// <param name="by">By mechanism to find the element</param> /// <returns>IWebElement object so that you can interction that object</returns> public IWebElement FindElement(By by) { FindElementEventArgs e = new FindElementEventArgs(this.parentDriver.WrappedDriver, this.underlyingElement, by); this.parentDriver.OnFindingElement(e); IWebElement element = this.underlyingElement.FindElement(by); this.parentDriver.OnFindElementCompleted(e); IWebElement wrappedElement = this.parentDriver.WrapElement(element); return wrappedElement; }
/// <summary> /// Find the first <see cref="IWebElement"/> using the given method. /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns>The first matching <see cref="IWebElement"/> on the current context.</returns> /// <exception cref="NoSuchElementException">If no element matches the criteria.</exception> public IWebElement FindElement(By by) { IWebElement wrappedElement = null; try { FindElementEventArgs e = new FindElementEventArgs(this.driver, by); this.OnFindingElement(e); IWebElement element = this.driver.FindElement(by); this.OnFindElementCompleted(e); wrappedElement = this.WrapElement(element); } catch (Exception ex) { this.OnException(new WebDriverExceptionEventArgs(this.driver, ex)); throw; } return wrappedElement; }
private static void FindElementCompleted(object sender, FindElementEventArgs e) { if (e.Element == null) { TestWebDriver.LogMessage(LogLevel.Verbose, "Found element from WebDriver: " + e.FindMethod); } else { TestWebDriver.LogMessage(LogLevel.Verbose, "Found element from WebElement: " + e.FindMethod); } if (!TestWebDriver.Settings.HighlightElements) return; if (TestWebDriver.PreviousElement != null) { TestWebDriver.Highlight(TestWebDriver.PreviousElement, true); } TestWebDriver.Highlight(TestWebDriver.CurrentElement); }
/// <summary> /// Raises the <see cref="E:OpenQA.Selenium.Support.Events.EventFiringWebDriver.FindElementCompleted"/> event. /// /// </summary> /// <param name="e">A <see cref="T:OpenQA.Selenium.Support.Events.FindElementEventArgs"/> that contains the event data.</param> protected virtual void OnFindElementCompleted(FindElementEventArgs e) { if (this.FindElementCompleted == null) return; this.FindElementCompleted((object) this, e); }
/// <summary> /// Finds the first element in the page that matches the <see cref="T:OpenQA.Selenium.By" /> object /// </summary> /// <param name="by">By mechanism to find the element</param> /// <returns> /// IWebElement object so that you can interaction that object /// </returns> public IWebElement FindElement(By by) { try { var e = new FindElementEventArgs(ParentDriver.WrappedDriver, WrappedElement, by); ParentDriver.OnFindingElement(e); var element = WrappedElement.FindElement(by); ParentDriver.OnFindElementCompleted(e); var f = new FoundElementEventArgs(ParentDriver.WrappedDriver, element, by); ParentDriver.OnFoundElement(f); return ParentDriver.WrapElement(element); } catch (Exception ex) { ParentDriver.OnException(new WebDriverExceptionEventArgs(ParentDriver, ex)); throw; } }
private void driver_FindElementCompleted(object sender, FindElementEventArgs e) { TestContext.CurrentContext.IncrementAssertCount(); }
public static void FindingElement(object sender, FindElementEventArgs e) { Console.WriteLine("Start searching for element using " + e.FindMethod); }
public static void FindElementCompleted(object sender, FindElementEventArgs e) { Console.WriteLine("Element was found using " + e.FindMethod); }
private void OnFindingElementCompleted(object sender, FindElementEventArgs findElementEventArgs) { SeleniumLog log = SeleniumLog.Instance(); if (log.Config.OnFindElement_LogAfterEvent) { log.Indent(); log.WriteLine("[Selenium Event] Element Found!", take_screenshot: log.Config.OnFindElement_TakeScreenshotAfterEvent); log.Unindent(); } }
private void OnFindingElement(object sender, FindElementEventArgs findElementEventArgs) { SeleniumLog log = SeleniumLog.Instance(); string[] FindMethodStr = findElementEventArgs.FindMethod.ToString().Split(':'); _by = FindMethodStr[0].Split('.')[1].Trim(); _locator = FindMethodStr[1].Trim(); if (log.Config.OnFindElement_LogBeforeEvent) { log.Indent(); log.WriteLine("[Selenium Event] Finding Element: " + findElementEventArgs.FindMethod, take_screenshot: log.Config.OnFindElement_TakeScreenshotBeforeEvent); //string[] FindMethodStr = findElementEventArgs.FindMethod.ToString().Split(':'); //_by = FindMethodStr[0].Split('.')[1].Trim(); //_locator = FindMethodStr[1].Trim(); //if (_by == "XPath") //{ // XPathTest.Test(driver, _locator); //} log.Unindent(); } }
/// <summary> /// Find all <see cref="T:OpenQA.Selenium.IWebElement">IWebElements</see> within the current context /// using the given mechanism. /// /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns> /// A <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1"/> of all <see cref="T:OpenQA.Selenium.IWebElement">WebElements</see> /// matching the current criteria, or an empty list if nothing matches. /// </returns> public ReadOnlyCollection<IWebElement> FindElements(By by) { List<IWebElement> list = new List<IWebElement>(); try { FindElementEventArgs e = new FindElementEventArgs(this.driver, by); this.OnFindingElement(e); ReadOnlyCollection<IWebElement> elements = this.driver.FindElements(by); this.OnFindElementCompleted(e); foreach (IWebElement underlyingElement in elements) { IWebElement webElement = this.WrapElement(underlyingElement); list.Add(webElement); FoundElementEventArgs f = new FoundElementEventArgs(driver, underlyingElement, by); this.OnFoundElement(f); } } catch (Exception ex) { this.OnException(new WebDriverExceptionEventArgs(this.driver, ex)); throw; } return list.AsReadOnly(); }
/// <summary> /// Raises the <see cref="E:OpenQA.Selenium.Support.Events.EventFiringWebDriver.FindingElement"/> event. /// /// </summary> /// <param name="e">A <see cref="T:OpenQA.Selenium.Support.Events.FindElementEventArgs"/> that contains the event data.</param> protected virtual void OnFindingElement(FindElementEventArgs e) { if (this.FindingElement == null) return; this.FindingElement((object) this, e); }
/// <summary> /// Find the first <see cref="T:OpenQA.Selenium.IWebElement" /> using the given method. /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns> /// The first matching <see cref="T:OpenQA.Selenium.IWebElement" /> on the current context. /// </returns> /// <exception cref="T:OpenQA.Selenium.NoSuchElementException">If no element matches the criteria.</exception> public IWebElement FindElement(By by) { try { var e = new FindElementEventArgs(WrappedDriver, by); OnFindingElement(e); var element = WrappedDriver.FindElements(by).FirstOrDefault(x => x.Displayed); OnFindElementCompleted(e); var f = new FoundElementEventArgs(WrappedDriver, element, by); OnFoundElement(f); return WrapElement(element); } catch (Exception ex) { OnException(new WebDriverExceptionEventArgs(WrappedDriver, ex)); throw; } }
private static void FindingElement(object sender, FindElementEventArgs e) { if (e.Element == null) { TestWebDriver.LogMessage(LogLevel.Verbose, "Finding element from WebDriver: " + e.FindMethod); } else { TestWebDriver.LogMessage(LogLevel.Verbose, "Finding element from WebElement: " + e.FindMethod); } }
/// <summary> /// Find all <see cref="T:OpenQA.Selenium.IWebElement">IWebElements</see> within the current context /// using the given mechanism. /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns> /// A <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1" /> of all /// <see cref="T:OpenQA.Selenium.IWebElement">WebElements</see> /// matching the current criteria, or an empty list if nothing matches. /// </returns> public ReadOnlyCollection<IWebElement> FindElements(By by) { var list = new List<IWebElement>(); try { var e = new FindElementEventArgs(WrappedDriver, by); OnFindingElement(e); var elements = WrappedDriver.FindElements(by).Where(x => x.Displayed); OnFindElementCompleted(e); foreach (var underlyingElement in elements) { var webElement = WrapElement(underlyingElement); list.Add(webElement); var f = new FoundElementEventArgs(WrappedDriver, underlyingElement, by); OnFoundElement(f); } } catch (Exception ex) { OnException(new WebDriverExceptionEventArgs(WrappedDriver, ex)); throw; } return list.AsReadOnly(); }
/// <summary> /// Finds the elements on the page by using the <see cref="By"/> object and returns a ReadOnlyCollection of the Elements on the page /// </summary> /// <param name="by">By mechanism to find the element</param> /// <returns>ReadOnlyCollection of IWebElement</returns> public ReadOnlyCollection<IWebElement> FindElements(By by) { List<IWebElement> wrappedElementList = new List<IWebElement>(); try { FindElementEventArgs e = new FindElementEventArgs(this.parentDriver.WrappedDriver, this.underlyingElement, by); this.parentDriver.OnFindingElement(e); ReadOnlyCollection<IWebElement> elements = this.underlyingElement.FindElements(by); this.parentDriver.OnFindElementCompleted(e); foreach (IWebElement element in elements) { IWebElement wrappedElement = this.parentDriver.WrapElement(element); wrappedElementList.Add(wrappedElement); } } catch (Exception ex) { this.parentDriver.OnException(new WebDriverExceptionEventArgs(this.parentDriver, ex)); throw; } return wrappedElementList.AsReadOnly(); }
/// <summary> /// Raises the <see cref="E:OpenQA.Selenium.Support.Events.EventFiringWebDriver.FindingElement" /> event. /// </summary> /// <param name="e">A <see cref="T:OpenQA.Selenium.Support.Events.FindElementEventArgs" /> that contains the event data.</param> protected virtual void OnFindingElement(FindElementEventArgs e) { if (FindingElement == null) return; FindingElement(this, e); }
void firingDriver_FindElementCompleted(object sender, FindElementEventArgs e) { log.Append("FindElementCompleted from ").Append(e.Element == null ? "IWebDriver " : "IWebElement ").AppendLine(e.FindMethod.ToString()); }
private string GetLogMessage(string command, FindElementEventArgs e = null, string param = "") { if (param != "") param = "'" + param + "'"; if (TestBase.testData.lastElement.name != "Element") { return string.Format(errorMessage, TestBase.GetCurrentClassAndMethodName(), command, TestBase.testData.lastElement.name, TestBase.testData.lastElement.by, param); } return string.Format(errorMessage, TestBase.GetCurrentClassAndMethodName(), command, "Element",e.FindMethod,param); }
/// <summary> /// Find the first <see cref="IWebElement"/> using the given method. /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns>The first matching <see cref="IWebElement"/> on the current context.</returns> /// <exception cref="NoSuchElementException">If no element matches the criteria.</exception> public IWebElement FindElement(By by) { FindElementEventArgs e = new FindElementEventArgs(this.driver, by); this.OnFindingElement(e); IWebElement element = this.driver.FindElement(by); this.OnFindElementCompleted(e); IWebElement wrappedElement = this.WrapElement(element); return wrappedElement; }
private void driver_FindElementCompleted(object sender, FindElementEventArgs e) { }
/// <summary> /// Raises the <see cref="FindElementCompleted"/> event. /// </summary> /// <param name="e">A <see cref="FindElementEventArgs"/> that contains the event data.</param> protected virtual void OnFindElementCompleted(FindElementEventArgs e) { if (this.FindElementCompleted != null) { this.FindElementCompleted(this, e); } }
/// <summary> /// Raises the <see cref="E:FindingElement" /> event. /// </summary> /// <param name="e">The <see cref="FindElementEventArgs"/> instance containing the event data.</param> protected override void OnFindingElement(FindElementEventArgs e) { Logger.Trace(CultureInfo.CurrentCulture, "OnFindingElement: {0}", e.FindMethod); base.OnFindingElement(e); }
/// <summary> /// Find the first <see cref="T:OpenQA.Selenium.IWebElement"/> using the given method. /// /// </summary> /// <param name="by">The locating mechanism to use.</param> /// <returns> /// The first matching <see cref="T:OpenQA.Selenium.IWebElement"/> on the current context. /// </returns> /// <exception cref="T:OpenQA.Selenium.NoSuchElementException">If no element matches the criteria.</exception> public IWebElement FindElement(By by) { try { FindElementEventArgs e = new FindElementEventArgs(this.driver, by); this.OnFindingElement(e); IWebElement element = this.driver.FindElement(by); this.OnFindElementCompleted(e); FoundElementEventArgs f= new FoundElementEventArgs(driver,element,by); this.OnFoundElement(f); return this.WrapElement(element); } catch (Exception ex) { this.OnException(new WebDriverExceptionEventArgs(this.driver, ex)); throw; } }