/// <summary> /// Simulates typing text into the element. /// </summary> /// <param name="text">The text to type into the element.</param> /// <remarks>The text to be typed may include special characters like arrow keys, /// backspaces, function keys, and so on. Valid special keys are defined in /// <see cref="Keys"/>.</remarks> /// <seealso cref="Keys"/> /// <exception cref="InvalidElementStateException">Thrown when the target element is not enabled.</exception> /// <exception cref="ElementNotVisibleException">Thrown when the target element is not visible.</exception> /// <exception cref="StaleElementReferenceException">Thrown when the target element is no longer valid in the document DOM.</exception> public void SendKeys(string text) { if (_frame.CefSharpDriver.FileDetector.IsFile(text)) { var before = NativeMethods.GetWindows(_frame.App.ProcessId); Click(); //wait for file dialog. while (true) { bool hit = false; foreach (var e in NativeMethods.GetWindows(_frame.App.ProcessId)) { if (!before.Contains(e)) { hit = true; break; } } if (hit) { break; } Thread.Sleep(10); } _frame.App.SendKeys(text); _frame.App.SendKey(System.Windows.Forms.Keys.Enter); return; } Execute(JsFocus()); CotnrolAccessor.SendKeys(text); }
/// <summary> /// Gets a <see cref="Screenshot"/> object representing the image of this element on the screen. /// </summary> /// <returns>A <see cref="Screenshot"/> object containing the image.</returns> public Screenshot GetScreenshot() { ScrollIntoView(); return(CotnrolAccessor.GetScreenShot(Location, Size)); }
internal CefSharpWebElement(CefSharpFrameDriver frame, CotnrolAccessor cotnrolAccessor, int index) { _frame = frame; CotnrolAccessor = cotnrolAccessor; Id = index; }