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
329 public bool? Checked
330 {
331 get
332 {
333 bool indeterminate = Attributes.ContainsKey("indeterminate")
334 && Attributes["indeterminate"] is bool
335 && true == (bool)Attributes["indeterminate"];
336
337 return true == indeterminate ? (bool?)null : Selected;
338 }
339 set { Attributes["selected"] = true == value; Attributes["indeterminate"] = null == value; }
340 }
341
343 public Point Location
344 {
345 get { return Attributes.ContainsKey("location") && Attributes["location"] is Point ? (Point)Attributes["location"] : new Point(0, 0); }
346 set { Attributes["location"] = value; }
347 }
348
353 internal CoordinateSpace CoordinateSpace
354 {
355 get { return Attributes.ContainsKey("coordinateSpace") && Attributes["coordinateSpace"] is CoordinateSpace ? (CoordinateSpace)Attributes["coordinateSpace"] : CoordinateSpace.Screen; }
356 set { Attributes["coordinateSpace"] = value; }
357 }
358
365 internal GPALElement ImageMatch { get; set; }
366
368 public Size Size
369 {
370 get { return Attributes.ContainsKey("size") && Attributes["size"] is Size ? (Size)Attributes["size"] : new Size(0, 0); }
371 set { Attributes["size"] = value; }
372 }
373
375 public bool Displayed
376 {
377 get
378 {
379 bool visibilty = true;
380 bool display = true;
381 bool opacity = true;
382
383 if (true == CssAttributes.ContainsKey("visibility"))
384 visibilty = CssAttributes["visibility"]?.ToString() != "hidden";
385
386 if (true == CssAttributes.ContainsKey("display"))
387 display = CssAttributes["display"]?.ToString() != "none";
388
389 if (true == CssAttributes.ContainsKey("opacity"))
390 opacity = CssAttributes["opacity"]?.ToString() != "0";
391
392 bool notHidden = visibilty && display && opacity;
393
394 bool hasSize = BoundingRect.Width > 0 && BoundingRect.Height > 0;
395
396 return notHidden && hasSize;
397 }
398 set { Attributes["displayed"] = value; }
399 }
400
402 public string Href
403 {
404 get { return Attributes.ContainsKey("href") ? Attributes["href"] as string : null; }
405 set { Attributes["href"] = value; }
406 }
407
409 public string Src
410 {
411 get { return Attributes.ContainsKey("src") ? Attributes["src"] as string : null; }
412 set { Attributes["src"] = value; }
413 }
414
416 public string Value
417 {
418 get { return Attributes.ContainsKey("value") ? Attributes["value"] as string : null; }
419 set { Attributes["value"] = value; }
420 }
421
423 public string Placeholder
424 {
425 get { return Attributes.ContainsKey("placeholder") ? Attributes["placeholder"] as string : null; }
426 set { Attributes["placeholder"] = value; }
427 }
428
430 public string Xpath
431 {
432 get { return Attributes.ContainsKey("xpath") ? Attributes["xpath"] as string : null; }
433 set { Attributes["xpath"] = value; }
434 }
435
438 {
439 get { return Attributes.ContainsKey("xpaths") && Attributes["xpaths"] is XPathInfo[]? (XPathInfo[])Attributes["xpaths"] : new XPathInfo[0]; }
440 set
441 {
442 Attributes["xpaths"] = value;
443 }
444 }
445
447 public string Css
448 {
449 get { return Attributes.ContainsKey("css") ? Attributes["css"] as string : null; }
450 set { Attributes["css"] = value; }
451 }
452
454 public string FullXPath
455 {
456 get { return Attributes.ContainsKey("fullXPath") ? Attributes["fullXPath"] as string : null; }
457 set { Attributes["fullXPath"] = value; }
458 }
459
462 {
463 get { return Attributes.ContainsKey("boundingRect") && Attributes["boundingRect"] is ClientRectangle ? (ClientRectangle)Attributes["boundingRect"] : null; }
464 set { Attributes["boundingRect"] = value; }
465 }
466
468 public string PageURL
469 {
470 get { return Attributes.ContainsKey("pageURL") ? Attributes["pageURL"] as string : null; }
471 set { Attributes["pageURL"] = value; }
472 }
473
475 public string Type
476 {
477 get { return Attributes.ContainsKey("type") ? Attributes["type"] as string : null; }
478 set { Attributes["type"] = value; }
479 }
480
481 internal GPALElement()
482 {
483 }
484
485 internal GPALElement(Browser.Browser browser)
486 {
487 Browser = browser;
488 }
489
493 internal GPALElement(Point location, Size size, string text, IWebDriver webDriver, string tagname = "img")
494 {
495 WrappedDriver = webDriver;
496 TagName = tagname;
497 Text = CleanText(text);
498 Location = location;
499 Size = size;
500 BoundingRect = new ClientRectangle(Location, Size);
501 }
502
503 internal GPALElement(IWebElement webElement, string attributeName = "")
504 {
505 iWebElement = webElement;
506 AttributeName = attributeName;
507 if (webElement != null)
508 {
509 TagName = webElement.TagName;
510 Text = CleanText(webElement.Text);
511 Enabled = webElement.Enabled;
512 Selected = webElement.Selected;
513 Location = webElement.Location;
514 Size = webElement.Size;
515 Displayed = webElement.Displayed;
516 Href = webElement.GetAttribute("href");
517 Src = webElement.GetAttribute("src");
518 Value = CleanText(webElement.GetAttribute("value"));
519 Placeholder = CleanText(webElement.GetAttribute("placeholder"));
520 Type = webElement.GetAttribute("type");
521
522 PageURL = WrappedDriver != null ? WrappedDriver.Url : null;
523
524 BoundingRect = new ClientRectangle(Location, Size);
525 }
526 }
527
541 internal GPALElement(IWebElement webElement, string attributeName, Dictionary<string, object> properties, string pageUrl)
542 {
543 iWebElement = webElement;
544 AttributeName = attributeName;
545
546 TagName = StringOf(properties, "tag");
547 Text = CleanText(StringOf(properties, "text"));
548 Enabled = BoolOf(properties, "enabled");
549 Selected = BoolOf(properties, "selected");
550 Attributes["indeterminate"] = BoolOf(properties, "indeterminate"); // the third state of a checkbox, which Checked answers with null
551 Displayed = BoolOf(properties, "displayed");
552 Location = new Point(IntOf(properties, "x"), IntOf(properties, "y"));
553 Size = new Size(IntOf(properties, "w"), IntOf(properties, "h"));
554 Href = StringOf(properties, "href");
555 Src = StringOf(properties, "src");
556 Value = CleanText(StringOf(properties, "value"));
557 Placeholder = CleanText(StringOf(properties, "placeholder"));
558 Type = StringOf(properties, "type");
559 PageURL = pageUrl;
560
561 BoundingRect = new ClientRectangle(Location, Size);
562 }
567 static string StringOf(Dictionary<string, object> properties, string name)
568 {
569 return true == properties.TryGetValue(name, out object value) ? value?.ToString() : null;
570 }
575 static bool BoolOf(Dictionary<string, object> properties, string name)
576 {
577 return true == properties.TryGetValue(name, out object value) && true == Convert.ToBoolean(value);
578 }
583 static int IntOf(Dictionary<string, object> properties, string name)
584 {
585 return true == properties.TryGetValue(name, out object value) && null != value ? Convert.ToInt32(value) : 0;
586 }
587
588 internal GPALElement(Dictionary<string, object> attributes, Browser.Browser browser)
589 {
590 WrappedDriver = browser.BrowserSettings.BrowserDriver;
591 Attributes = attributes ?? new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
592 Browser = browser;
593 }
594
596 public void Clear()
597 {
598 if (iWebElement != null)
599 try
600 {
601 iWebElement.Clear();
602 }
603 catch { }
604 }
605
607 public void Click(ModifierKeys modifierKeys)
608 {
609 string currentUrl = Browser.BrowserSettings.CurrentURL;
610 Browser.CurrentUOW.ActionCalled = true;
611
612 BrowserHelper.TopBrowser(Browser, false);
613 ElementHelper.Click(Browser, Selector, this, ClickType.LeftClick, modifierKeys);
614
615 string currentUrl2 = Browser.GetSetCurrentUrl();
616
617 if (false == UrlHelper.AreEquivalent(currentUrl, currentUrl2))
618 BrowserHelper.CheckDocumentReady(Browser); // just a simple document ready check
619 }
620
622 public void Click()
623 {
624 Click(ModifierKeys.NONE);
625 }
626
628 public void MiddleClick(ModifierKeys modifierKeys = ModifierKeys.NONE)
629 {
630 Browser.CurrentUOW.ActionCalled = true;
631 BrowserHelper.TopBrowser(Browser, false);
632 ElementHelper.Click(Browser, Selector, this, ClickType.MiddleClick, modifierKeys);
633 //BrowserHelper.CheckDocumentReady(Browser); // just a simple document ready check
634 }
635
637 public void Hide()
638 {
639 Browser.CurrentUOW.ActionCalled = true;
640 ElementHelper.Hide(Browser, this);
641 }
642
644 public IWebElement FindElement(By by)
645 {
646 if (iWebElement != null)
647 return iWebElement.FindElement(by);
648 throw new NoSuchElementException("Element not found using " + by);
649 }
650
652 public ReadOnlyCollection<IWebElement> FindElements(By by)
653 {
654 if (iWebElement != null)
655 return iWebElement.FindElements(by);
656 return new ReadOnlyCollection<IWebElement>(new List<IWebElement>());
657 }
658
660 public string GetAttribute(string attributeName)
661 {
662 string seleniumValue = null;
663
664 if (iWebElement != null)
665 seleniumValue = iWebElement.GetAttribute(char.ToUpper(attributeName[0]) + attributeName.Substring(1)); // NOTE: ours are lowercase, so search selenium as capitalized (TagName will get ours)
666
667 if (null == seleniumValue)
668 if (Attributes.ContainsKey(attributeName))
669 {
670 object value = Attributes[attributeName];
671 if (value is Point p)
672 return string.Format("({0},{1})", p.X, p.Y);
673 if (value is Size s)
674 return string.Format("({0},{1})", s.Width, s.Height);
675 if (value is XPathInfo[] arr)
676 return string.Join("; ", arr.Select(x => string.Format("{0} ({1})", x.Xpath, x.MatchedElements)));
677 if (value is ClientRectangle r)
678 return string.Format("(top={0}, left={1}, bottom={2}, right={3}, x={4}, y={5}, width={6}, height={7})",
679 r.Top, r.Left, r.Bottom, r.Right, r.X, r.Y, r.Width, r.Height);
680 if (value == null)
681 return null;
682 return value.ToString();
683 }
684
685 PropertyInfo property = GetType().GetProperty(attributeName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
686 if (property != null && property.CanRead)
687 return property.GetValue(this, null)?.ToString();
688
689 return null;
690 }
691
701 public void SetAttribute(string attributeName, string value)
702 {
703 ElementHelper.SetAttribute(Browser, this, attributeName, value);
704 }
705
707 public string GetCssValue(string propertyName)
708 {
709 return iWebElement != null ? iWebElement.GetCssValue(propertyName) : CssAttributes[propertyName];
710 }
711
713 public string GetDomAttribute(string attributeName)
714 {
715 return iWebElement != null ? iWebElement.GetDomAttribute(attributeName) : DomAttributes[attributeName];
716 }
717
719 public string GetDomProperty(string propertyName)
720 {
721 return iWebElement != null ? iWebElement.GetDomProperty(propertyName) : DomProperties[propertyName];
722 }
723
725 public ISearchContext GetShadowRoot()
726 {
727 // using puppeteer, ShadowRoot will be populated
728 var shadowRoot = iWebElement != null ? iWebElement.GetShadowRoot() : ShadowRoot;
729
730 return shadowRoot;
731 }
732
734 public void SendKeys(string text)
735 {
736 if (iWebElement != null)
737 iWebElement.SendKeys(text);
738 }
739
741 public void Submit()
742 {
743 if (iWebElement != null)
744 iWebElement.Submit();
745 }
746
748 public bool IsDisabled()
749 {
750 bool attrDisabled = Attributes.ContainsKey("disabled") && Attributes["disabled"].ToString() == "true";
751 bool propDisabled = false;
752
753 if (DomProperties.ContainsKey("disabled"))
754 propDisabled = DomProperties["disabled"].ToString() == "true";
755
756 return attrDisabled || propDisabled;
757 }
758
760 public bool IsEnabled()
761 {
762 return !IsDisabled();
763 }
764
769 public bool IsClickable(bool publishEvent = true)
770 {
771 bool isClickable = true;
772
773 if (true == Browser.UseOttoMagic)
774 isClickable = Browser.MagicHelper.IsClickAble(Css);
775 //else if (true == Browser.UsePuppeteer)
776 // isClickable = Browser.PuppeteerClient.IsClickable(Css).Execute<bool>();
777 else // selenium
778 {
779 bool notDisabled = !IsDisabled();
780
781 bool ariaDisabled =
782 Attributes.TryGetValue("aria-disabled", out var aria) &&
783 aria.ToString().Equals("true", StringComparison.OrdinalIgnoreCase);
784
785 bool pointerOk = true;
786 if (true == CssAttributes.TryGetValue("pointer-events", out var pe))
787 pointerOk = pe.ToString() != "none";
788
789 isClickable =
790 Displayed &&
791 notDisabled &&
792 !ariaDisabled &&
793 pointerOk;
794
795 if (false == isClickable && true == publishEvent)
797 GPALEventType.WARNING,
798 $"Element [{TagName}] does not appear clickable.",
799 this,
800 GPALObjectType.Other);
801 }
802
803 return true;
804 }
805
806 // release any CDP created nodes and free up memory
807 private bool disposed = false;
808
812 public async Task DisposeAsync() // or void Dispose() with fire-and-forget
813 {
814 if (disposed || string.IsNullOrEmpty(ElementHandle)) return;
815
816 if (true == Browser.UsePuppeteer)
817 try
818 {
819 // Use the same communicator/session that created it, or a global one
820 await Browser.PuppeteerCommunicator.SendCommand<object>(
821 DevToolsMethods.RuntimeReleaseObject,
822 new { objectId = ElementHandle },
823 null); // however you track the right session
824 }
825 catch
826 {
827 // Session might already be detached — safe to ignore
828 }
829
830 ElementHandle = null;
831 disposed = true;
832 }
833
837 public void Dispose()
838 {
839 _ = DisposeAsync(); // fire-and-forget if in sync context
840 }
841
842 static string CleanText(string str) => str is null ? null : System.Text.RegularExpressions.Regex.Replace(str, @"\s+", " ").Trim();
843 }
844}
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.
bool? Checked
A checkbox's state, which has three of them: true ticked, false clear, and null for the third one,...
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:2568
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.