GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
GPALElement.cs
1// =============================================================================
2// GPAL - Generally Positive Automation Library
3// Copyright © 2026 Software Decisions, Inc. All rights reserved.
4//
5// This file is part of GPAL.
6// Licensed under the Business Source License 1.1
7//
8// Primary development, architecture, and vision by Michael B. Vederman,
9// CEO of Software Decisions, Inc., Texas.
10//
11// Internal development maintained privately.
12// Public releases appear on GitHub: https://github.com/SoftwareDecisionsInc/GPAL.
13//
14// See LICENSE for full terms, including Additional Use Grant.
15// =============================================================================
16
17using System;
18using System.Collections.Generic;
19using System.Collections.ObjectModel;
20using System.Drawing;
21using System.Linq;
22using System.Text;
23using System.Threading.Tasks;
24using OpenQA.Selenium;
25using static GenerallyPositive.Enums;
27using System.Reflection;
28using DocumentFormat.OpenXml.Spreadsheet;
29
30
31namespace GenerallyPositive
32{
36 public class XPathInfo
37 {
41 public string Xpath { get; set; }
42
46 public int MatchedElements { get; set; }
47
53 public XPathInfo(string xpath, int matchedElements)
54 {
55 Xpath = xpath;
56 MatchedElements = matchedElements;
57 }
58 }
59
63 public class ClientRectangle
64 {
66 public float Top { get; set; }
68 public float Left { get; set; }
70 public float Bottom { get; set; }
72 public float Right { get; set; }
74 public float X { get; set; }
76 public float Y { get; set; }
78 public float Width { get; set; }
80 public float Height { get; set; }
81
85 public Size Size
86 {
87 get => new Size((int)Width, (int)Height);
88 set
89 {
90 Width = value.Width;
91 Height = value.Height;
92 }
93 }
94
99 public Dictionary<string, object> ToDictionary()
100 {
101 return new Dictionary<string, object>
102 {
103 { nameof(Top), Top },
104 { nameof(Left), Left },
105 { nameof(Bottom), Bottom },
106 { nameof(Right), Right },
107 { nameof(X), X },
108 { nameof(Y), Y },
109 { nameof(Width), Width },
110 { nameof(Height), Height }
111 };
112 }
113
114 internal ClientRectangle(Point point, Size size)
115 {
116 Top = point.Y;
117 Left = point.X;
118 Width = size.Width;
119 Height = size.Height;
120 }
121
126 {
127 }
128
132 public bool IsEmpty =>
133 X == 0 && Y == 0 && Width == 0 && Height == 0;
134 }
135
142 public class GPALElement : IGPALElement, IDisposable
143 {
147 public Browser.Browser Browser { get; internal set; }
148
152 public GPALElement ShadowRoot { get; internal set; }
153
157 public Dictionary<string, object> Attributes { get; set; } = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
158
159 private Dictionary<string, object> _cssAttributes;
163 public Dictionary<string, object> CssAttributes
164 {
165 get
166 {
167 if (null == _cssAttributes)
168 {
169 GPAL.PublishSimpleEvent(GPALEventType.DEBUG, $"Getting Css Attributes for element [{TagName}]", this, GPALObjectType.Other);
170
171 if (Browser.UsePuppeteer)
172 _cssAttributes = Browser.PuppeteerClient.GetCssAttributes(ElementBackendNodeId.ToString()).Execute<Dictionary<string, object>>();
173 else if (Browser.UseOttoMagic)
174 _cssAttributes = Browser.MagicHelper.GetCssAttributes(Css);
175 else
176 _cssAttributes = ElementHelper.GetCssAttributes(Browser, WebElement);
177
178 if (null == _cssAttributes)
179 _cssAttributes = new Dictionary<string, object>();
180
181 GPAL.PublishSimpleEvent(GPALEventType.DEBUG, $"Got [{_cssAttributes.Count}] Css Attributes for element [{TagName}]", this, GPALObjectType.Other);
182 }
183 return _cssAttributes;
184 }
185 set => _cssAttributes = value;
186 }
187
188 private Dictionary<string, object> _domAttributes;
192 public Dictionary<string, object> DomAttributes
193 {
194 get
195 {
196 if (null == _domAttributes)
197 {
198 GPAL.PublishSimpleEvent(GPALEventType.DEBUG, $"Getting Dom Attributes for element [{TagName}]", this, GPALObjectType.Other);
199
200 if (Browser.UsePuppeteer)
201 _domAttributes = Browser.PuppeteerClient.GetDomAttributes(ElementBackendNodeId.ToString()).Execute<Dictionary<string, object>>();
202 else if (Browser.UseOttoMagic)
203 _domAttributes = Browser.MagicHelper.GetDomAttributes(Css);
204 else
205 _domAttributes = ElementHelper.GetDomAttributes(Browser, WebElement);
206
207 if (null == _domAttributes)
208 _domAttributes = new Dictionary<string, object>();
209
210 GPAL.PublishSimpleEvent(GPALEventType.DEBUG, $"Got [{_domAttributes.Count}] Dom Attributes for element [{TagName}]", this, GPALObjectType.Other);
211 }
212 return _domAttributes;
213 }
214 set => _domAttributes = value;
215 }
216
217 private Dictionary<string, object> _domProperties;
221 public Dictionary<string, object> DomProperties
222 {
223 get
224 {
225 if (null == _domProperties)
226 {
227 GPAL.PublishSimpleEvent(GPALEventType.DEBUG, $"Getting Dom Properties for element [{TagName}]", this, GPALObjectType.Other);
228
229 if (Browser.UsePuppeteer)
230 _domProperties = Browser.PuppeteerClient.GetDomProperties(ElementBackendNodeId.ToString()).Execute<Dictionary<string, object>>();
231 else if (Browser.UseOttoMagic)
232 _domProperties = Browser.MagicHelper.GetDomProperties(Css);
233 else
234 _domProperties = ElementHelper.GetDomProperties(Browser, WebElement);
235
236 if (null == _domProperties)
237 _domProperties = new Dictionary<string, object>();
238
239 GPAL.PublishSimpleEvent(GPALEventType.DEBUG, $"Got [{_domProperties.Count}] Dom Properties for element [{TagName}]", this, GPALObjectType.Other);
240 }
241 return _domProperties;
242 }
243 set => _domProperties = value;
244 }
245
249 public IWebDriver WrappedDriver { get; set; }
250
251 internal dynamic iWebElement;
255 public dynamic WebElement
256 {
257 get => iWebElement;
258 internal set => iWebElement = value;
259 }
260
261 public string ElementHandle { get; set; } // objectId for puppeteer
262 public int ElementNodeId { get; set; }
263 public int ElementBackendNodeId { get; set; }
264 internal long? ContextId { get; set; }
265 internal bool IsShadowRoot { get; set; } = false;
271 internal bool IsClosedShadowRoot { get; set; } = false;
272
276 public Selector Selector { get; internal set; }
277
278 // ==================== Existing Properties ====================
279
281 public string Name
282 {
283 get { return Attributes.ContainsKey("name") ? Attributes["name"] as string : null; }
284 set { Attributes["name"] = value; }
285 }
286
288 public string AttributeName
289 {
290 get { return Attributes.ContainsKey("attributeName") ? Attributes["attributeName"] as string : null; }
291 set { Attributes["attributeName"] = value; }
292 }
293
295 public string TagName
296 {
297 get { return Attributes.ContainsKey("tagName") ? Attributes["tagName"].ToString() : null; }
298 set { Attributes["tagName"] = value; }
299 }
300
302 public string Text
303 {
304 get { return Attributes.ContainsKey("text") ? Attributes["text"] as string : null; }
305 set { Attributes["text"] = value; }
306 }
307
309 public bool Enabled
310 {
311 get { return Attributes.ContainsKey("enabled") && Attributes["enabled"] is bool ? (bool)Attributes["enabled"] : false; }
312 set { Attributes["enabled"] = value; }
313 }
314
316 public bool Selected
317 {
318 get { return Attributes.ContainsKey("selected") && Attributes["selected"] is bool ? (bool)Attributes["selected"] : false; }
319 set { Attributes["selected"] = value; }
320 }
321
323 public Point Location
324 {
325 get { return Attributes.ContainsKey("location") && Attributes["location"] is Point ? (Point)Attributes["location"] : new Point(0, 0); }
326 set { Attributes["location"] = value; }
327 }
328
333 internal CoordinateSpace CoordinateSpace
334 {
335 get { return Attributes.ContainsKey("coordinateSpace") && Attributes["coordinateSpace"] is CoordinateSpace ? (CoordinateSpace)Attributes["coordinateSpace"] : CoordinateSpace.Screen; }
336 set { Attributes["coordinateSpace"] = value; }
337 }
338
340 public Size Size
341 {
342 get { return Attributes.ContainsKey("size") && Attributes["size"] is Size ? (Size)Attributes["size"] : new Size(0, 0); }
343 set { Attributes["size"] = value; }
344 }
345
347 public bool Displayed
348 {
349 get
350 {
351 bool visibilty = true;
352 bool display = true;
353 bool opacity = true;
354
355 if (true == CssAttributes.ContainsKey("visibility"))
356 visibilty = CssAttributes["visibility"]?.ToString() != "hidden";
357
358 if (true == CssAttributes.ContainsKey("display"))
359 display = CssAttributes["display"]?.ToString() != "none";
360
361 if (true == CssAttributes.ContainsKey("opacity"))
362 opacity = CssAttributes["opacity"]?.ToString() != "0";
363
364 bool notHidden = visibilty && display && opacity;
365
366 bool hasSize = BoundingRect.Width > 0 && BoundingRect.Height > 0;
367
368 return notHidden && hasSize;
369 }
370 set { Attributes["displayed"] = value; }
371 }
372
374 public string Href
375 {
376 get { return Attributes.ContainsKey("href") ? Attributes["href"] as string : null; }
377 set { Attributes["href"] = value; }
378 }
379
381 public string Src
382 {
383 get { return Attributes.ContainsKey("src") ? Attributes["src"] as string : null; }
384 set { Attributes["src"] = value; }
385 }
386
388 public string Value
389 {
390 get { return Attributes.ContainsKey("value") ? Attributes["value"] as string : null; }
391 set { Attributes["value"] = value; }
392 }
393
395 public string Placeholder
396 {
397 get { return Attributes.ContainsKey("placeholder") ? Attributes["placeholder"] as string : null; }
398 set { Attributes["placeholder"] = value; }
399 }
400
402 public string Xpath
403 {
404 get { return Attributes.ContainsKey("xpath") ? Attributes["xpath"] as string : null; }
405 set { Attributes["xpath"] = value; }
406 }
407
410 {
411 get { return Attributes.ContainsKey("xpaths") && Attributes["xpaths"] is XPathInfo[]? (XPathInfo[])Attributes["xpaths"] : new XPathInfo[0]; }
412 set
413 {
414 Attributes["xpaths"] = value;
415 }
416 }
417
419 public string Css
420 {
421 get { return Attributes.ContainsKey("css") ? Attributes["css"] as string : null; }
422 set { Attributes["css"] = value; }
423 }
424
426 public string FullXPath
427 {
428 get { return Attributes.ContainsKey("fullXPath") ? Attributes["fullXPath"] as string : null; }
429 set { Attributes["fullXPath"] = value; }
430 }
431
434 {
435 get { return Attributes.ContainsKey("boundingRect") && Attributes["boundingRect"] is ClientRectangle ? (ClientRectangle)Attributes["boundingRect"] : null; }
436 set { Attributes["boundingRect"] = value; }
437 }
438
440 public string PageURL
441 {
442 get { return Attributes.ContainsKey("pageURL") ? Attributes["pageURL"] as string : null; }
443 set { Attributes["pageURL"] = value; }
444 }
445
447 public string Type
448 {
449 get { return Attributes.ContainsKey("type") ? Attributes["type"] as string : null; }
450 set { Attributes["type"] = value; }
451 }
452
453 internal GPALElement()
454 {
455 }
456
457 internal GPALElement(Browser.Browser browser)
458 {
459 Browser = browser;
460 }
461
465 internal GPALElement(Point location, Size size, string text, IWebDriver webDriver, string tagname = "img")
466 {
467 WrappedDriver = webDriver;
468 TagName = tagname;
469 Text = CleanText(text);
470 Location = location;
471 Size = size;
472 BoundingRect = new ClientRectangle(Location, Size);
473 }
474
475 internal GPALElement(IWebElement webElement, string attributeName = "")
476 {
477 iWebElement = webElement;
478 AttributeName = attributeName;
479 if (webElement != null)
480 {
481 TagName = webElement.TagName;
482 Text = CleanText(webElement.Text);
483 Enabled = webElement.Enabled;
484 Selected = webElement.Selected;
485 Location = webElement.Location;
486 Size = webElement.Size;
487 Displayed = webElement.Displayed;
488 Href = webElement.GetAttribute("href");
489 Src = webElement.GetAttribute("src");
490 Value = CleanText(webElement.GetAttribute("value"));
491 Placeholder = CleanText(webElement.GetAttribute("placeholder"));
492 Type = webElement.GetAttribute("type");
493
494 PageURL = WrappedDriver != null ? WrappedDriver.Url : null;
495
496 BoundingRect = new ClientRectangle(Location, Size);
497 }
498 }
499
513 internal GPALElement(IWebElement webElement, string attributeName, Dictionary<string, object> properties, string pageUrl)
514 {
515 iWebElement = webElement;
516 AttributeName = attributeName;
517
518 TagName = StringOf(properties, "tag");
519 Text = CleanText(StringOf(properties, "text"));
520 Enabled = BoolOf(properties, "enabled");
521 Selected = BoolOf(properties, "selected");
522 Displayed = BoolOf(properties, "displayed");
523 Location = new Point(IntOf(properties, "x"), IntOf(properties, "y"));
524 Size = new Size(IntOf(properties, "w"), IntOf(properties, "h"));
525 Href = StringOf(properties, "href");
526 Src = StringOf(properties, "src");
527 Value = CleanText(StringOf(properties, "value"));
528 Placeholder = CleanText(StringOf(properties, "placeholder"));
529 Type = StringOf(properties, "type");
530 PageURL = pageUrl;
531
532 BoundingRect = new ClientRectangle(Location, Size);
533 }
538 static string StringOf(Dictionary<string, object> properties, string name)
539 {
540 return true == properties.TryGetValue(name, out object value) ? value?.ToString() : null;
541 }
546 static bool BoolOf(Dictionary<string, object> properties, string name)
547 {
548 return true == properties.TryGetValue(name, out object value) && true == Convert.ToBoolean(value);
549 }
554 static int IntOf(Dictionary<string, object> properties, string name)
555 {
556 return true == properties.TryGetValue(name, out object value) && null != value ? Convert.ToInt32(value) : 0;
557 }
558
559 internal GPALElement(Dictionary<string, object> attributes, Browser.Browser browser)
560 {
561 WrappedDriver = browser.BrowserSettings.BrowserDriver;
562 Attributes = attributes ?? new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
563 Browser = browser;
564 }
565
567 public void Clear()
568 {
569 if (iWebElement != null)
570 try
571 {
572 iWebElement.Clear();
573 }
574 catch { }
575 }
576
578 public void Click(ModifierKeys modifierKeys)
579 {
580 string currentUrl = Browser.BrowserSettings.CurrentURL;
581 Browser.CurrentUOW.ActionCalled = true;
582
583 BrowserHelper.TopBrowser(Browser, false);
584 ElementHelper.Click(Browser, Selector, this, ClickType.LeftClick, modifierKeys);
585
586 string currentUrl2 = Browser.GetSetCurrentUrl();
587
588 if (false == UrlHelper.AreEquivalent(currentUrl, currentUrl2))
589 BrowserHelper.CheckDocumentReady(Browser); // just a simple document ready check
590 }
591
593 public void Click()
594 {
595 Click(ModifierKeys.NONE);
596 }
597
599 public void MiddleClick(ModifierKeys modifierKeys = ModifierKeys.NONE)
600 {
601 Browser.CurrentUOW.ActionCalled = true;
602 BrowserHelper.TopBrowser(Browser, false);
603 ElementHelper.Click(Browser, Selector, this, ClickType.MiddleClick, modifierKeys);
604 //BrowserHelper.CheckDocumentReady(Browser); // just a simple document ready check
605 }
606
608 public void Hide()
609 {
610 Browser.CurrentUOW.ActionCalled = true;
611 ElementHelper.Hide(Browser, this);
612 }
613
615 public IWebElement FindElement(By by)
616 {
617 if (iWebElement != null)
618 return iWebElement.FindElement(by);
619 throw new NoSuchElementException("Element not found using " + by);
620 }
621
623 public ReadOnlyCollection<IWebElement> FindElements(By by)
624 {
625 if (iWebElement != null)
626 return iWebElement.FindElements(by);
627 return new ReadOnlyCollection<IWebElement>(new List<IWebElement>());
628 }
629
631 public string GetAttribute(string attributeName)
632 {
633 string seleniumValue = null;
634
635 if (iWebElement != null)
636 seleniumValue = iWebElement.GetAttribute(char.ToUpper(attributeName[0]) + attributeName.Substring(1)); // NOTE: ours are lowercase, so search selenium as capitalized (TagName will get ours)
637
638 if (null == seleniumValue)
639 if (Attributes.ContainsKey(attributeName))
640 {
641 object value = Attributes[attributeName];
642 if (value is Point p)
643 return string.Format("({0},{1})", p.X, p.Y);
644 if (value is Size s)
645 return string.Format("({0},{1})", s.Width, s.Height);
646 if (value is XPathInfo[] arr)
647 return string.Join("; ", arr.Select(x => string.Format("{0} ({1})", x.Xpath, x.MatchedElements)));
648 if (value is ClientRectangle r)
649 return string.Format("(top={0}, left={1}, bottom={2}, right={3}, x={4}, y={5}, width={6}, height={7})",
650 r.Top, r.Left, r.Bottom, r.Right, r.X, r.Y, r.Width, r.Height);
651 if (value == null)
652 return null;
653 return value.ToString();
654 }
655
656 PropertyInfo property = GetType().GetProperty(attributeName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
657 if (property != null && property.CanRead)
658 return property.GetValue(this, null)?.ToString();
659
660 return null;
661 }
662
672 public void SetAttribute(string attributeName, string value)
673 {
674 ElementHelper.SetAttribute(Browser, this, attributeName, value);
675 }
676
678 public string GetCssValue(string propertyName)
679 {
680 return iWebElement != null ? iWebElement.GetCssValue(propertyName) : CssAttributes[propertyName];
681 }
682
684 public string GetDomAttribute(string attributeName)
685 {
686 return iWebElement != null ? iWebElement.GetDomAttribute(attributeName) : DomAttributes[attributeName];
687 }
688
690 public string GetDomProperty(string propertyName)
691 {
692 return iWebElement != null ? iWebElement.GetDomProperty(propertyName) : DomProperties[propertyName];
693 }
694
696 public ISearchContext GetShadowRoot()
697 {
698 // using puppeteer, ShadowRoot will be populated
699 var shadowRoot = iWebElement != null ? iWebElement.GetShadowRoot() : ShadowRoot;
700
701 return shadowRoot;
702 }
703
705 public void SendKeys(string text)
706 {
707 if (iWebElement != null)
708 iWebElement.SendKeys(text);
709 }
710
712 public void Submit()
713 {
714 if (iWebElement != null)
715 iWebElement.Submit();
716 }
717
719 public bool IsDisabled()
720 {
721 bool attrDisabled = Attributes.ContainsKey("disabled") && Attributes["disabled"].ToString() == "true";
722 bool propDisabled = false;
723
724 if (DomProperties.ContainsKey("disabled"))
725 propDisabled = DomProperties["disabled"].ToString() == "true";
726
727 return attrDisabled || propDisabled;
728 }
729
731 public bool IsEnabled()
732 {
733 return !IsDisabled();
734 }
735
740 public bool IsClickable(bool publishEvent = true)
741 {
742 bool isClickable = true;
743
744 if (true == Browser.UseOttoMagic)
745 isClickable = Browser.MagicHelper.IsClickAble(Css);
746 //else if (true == Browser.UsePuppeteer)
747 // isClickable = Browser.PuppeteerClient.IsClickable(Css).Execute<bool>();
748 else // selenium
749 {
750 bool notDisabled = !IsDisabled();
751
752 bool ariaDisabled =
753 Attributes.TryGetValue("aria-disabled", out var aria) &&
754 aria.ToString().Equals("true", StringComparison.OrdinalIgnoreCase);
755
756 bool pointerOk = true;
757 if (true == CssAttributes.TryGetValue("pointer-events", out var pe))
758 pointerOk = pe.ToString() != "none";
759
760 isClickable =
761 Displayed &&
762 notDisabled &&
763 !ariaDisabled &&
764 pointerOk;
765
766 if (false == isClickable && true == publishEvent)
768 GPALEventType.WARNING,
769 $"Element [{TagName}] does not appear clickable.",
770 this,
771 GPALObjectType.Other);
772 }
773
774 return true;
775 }
776
777 // release any CDP created nodes and free up memory
778 private bool disposed = false;
779
783 public async Task DisposeAsync() // or void Dispose() with fire-and-forget
784 {
785 if (disposed || string.IsNullOrEmpty(ElementHandle)) return;
786
787 if (true == Browser.UsePuppeteer)
788 try
789 {
790 // Use the same communicator/session that created it, or a global one
791 await Browser.PuppeteerCommunicator.SendCommand<object>(
792 DevToolsMethods.RuntimeReleaseObject,
793 new { objectId = ElementHandle },
794 null); // however you track the right session
795 }
796 catch
797 {
798 // Session might already be detached — safe to ignore
799 }
800
801 ElementHandle = null;
802 disposed = true;
803 }
804
808 public void Dispose()
809 {
810 _ = DisposeAsync(); // fire-and-forget if in sync context
811 }
812
813 static string CleanText(string str) => str is null ? null : System.Text.RegularExpressions.Regex.Replace(str, @"\s+", " ").Trim();
814 }
815}
Browser object that contains the fluent methods to create your Browser workflow. Instatiated using G...
Definition Browser.cs:68
Represents a client-side bounding rectangle (similar to DOMRect) with additional convenience properti...
float Top
Gets or sets the top coordinate.
float Right
Gets or sets the right coordinate.
float Bottom
Gets or sets the bottom coordinate.
Dictionary< string, object > ToDictionary()
Converts the rectangle properties to a dictionary for easy serialization or logging.
float Y
Gets or sets the Y coordinate.
ClientRectangle()
Creates an empty ClientRectangle.
float Height
Gets or sets the height.
Size Size
Gets or sets the Size as a System.Drawing.Size.
bool IsEmpty
Determines whether the rectangle has zero dimensions and position.
float Left
Gets or sets the left coordinate.
float Width
Gets or sets the width.
float X
Gets or sets the X coordinate.
Pseudo element used in Applications and Browser workflows for image matching and unified automation....
void MiddleClick(ModifierKeys modifierKeys=ModifierKeys.NONE)
Performs a middle mouse button click.
string Xpath
XPath used to locate this element.
bool Displayed
Whether the element is visible on the page.
async Task DisposeAsync()
Asynchronously releases resources (especially Puppeteer object handles).
bool IsClickable(bool publishEvent=true)
Determines whether the element appears clickable based on visibility, disabled state,...
bool IsDisabled()
Checks if the element is disabled via attributes or properties.
string PageURL
Current page URL when the element was captured.
string Text
Visible text content of the element.
string Placeholder
placeholder attribute.
Dictionary< string, object > Attributes
All raw attributes returned from the automation backend.
string Type
The type of the element, for input, this can be many.
string Name
Name attribute of the element.
Size Size
Dimensions of the element.
void Click(ModifierKeys modifierKeys)
Performs a click with optional keyboard modifiers.
bool IsEnabled()
Checks if the element is enabled.
IWebElement FindElement(By by)
Finds a child element using Selenium By locator.
void SendKeys(string text)
Sends keystrokes to the element.
string GetDomAttribute(string attributeName)
Gets a DOM attribute.
Dictionary< string, object > CssAttributes
CSS computed style properties for the element.
bool Selected
Whether the element is selected (e.g. checkboxes, radio buttons).
string GetCssValue(string propertyName)
Gets a computed CSS value.
string TagName
HTML tag name of the element.
void Click()
Performs a standard left click.
Browser.Browser Browser
Associated Browser instance.
string GetAttribute(string attributeName)
Gets an attribute value with fallback to internal dictionary.
void Submit()
Submits the form if the element is part of one.
Point Location
Screen coordinates of the element.
GPALElement ShadowRoot
Shadow root if the element contains one.
string Value
value attribute (inputs, textareas, etc.).
ISearchContext GetShadowRoot()
Returns the ShadowRoot if available.
void SetAttribute(string attributeName, string value)
Directly sets a DOM attribute on this element via element.setAttribute(attributeName,...
string AttributeName
Custom attribute name (used internally).
void Hide()
Hides the element via JavaScript (sets display:none).
string FullXPath
Full absolute XPath.
string Css
CSS selector used to locate this element.
ClientRectangle BoundingRect
Client bounding rectangle with detailed coordinates.
string GetDomProperty(string propertyName)
Gets a DOM property.
Dictionary< string, object > DomAttributes
DOM attributes of the element.
void Clear()
Clears the element's value (if supported by underlying element).
string Href
href attribute (for links).
Dictionary< string, object > DomProperties
DOM properties of the element.
IWebDriver WrappedDriver
The underlying Selenium WebDriver instance.
void Dispose()
Disposes the element (fire-and-forget async cleanup).
bool Enabled
Whether the element is enabled.
Selector Selector
Selector used to locate this element.
XPathInfo[] Xpaths
Array of alternative XPaths with match counts.
string Src
src attribute (for images, scripts, etc.).
dynamic WebElement
The wrapped Selenium IWebElement or internal dynamic element.
ReadOnlyCollection< IWebElement > FindElements(By by)
Finds all child elements using Selenium By locator.
Everything starts here, all the GPAL controls and global settings using fluent syntax are here....
Definition GPAL.cs:49
static void PublishSimpleEvent(GPALEventType gPALEventType, string msg, dynamic gPALObject=null, Enums.GPALObjectType gPALObjectType=GPALObjectType.None, Exception ex=null)
Publish a message to either the information channel or exception channel (if exception passed in) Pub...
Definition GPAL.cs:2406
Represents XPath matching information returned by advanced selector strategies.
XPathInfo(string xpath, int matchedElements)
Creates a new XPathInfo instance.
int MatchedElements
Number of elements matched by this XPath on the page.
string Xpath
The generated XPath expression.