Finds all elements matching the criteria. An object to use to search for the elements. A of all WebElements matching the current criteria, or an empty list if nothing matches. If <paramref name="cont
(ISearchContext context)
| 85 | /// matching the current criteria, or an empty list if nothing matches.</returns> |
| 86 | /// <exception cref="ArgumentException">If <paramref name="context"/> is not <see cref="IJavaScriptExecutor"/> or wraps a driver that does.</exception> |
| 87 | public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context) |
| 88 | { |
| 89 | IJavaScriptExecutor js = GetExecutor(context); |
| 90 | Dictionary<string, object> parameters = new Dictionary<string, object>(); |
| 91 | Dictionary<string, object> filterParameters = new Dictionary<string, object>(); |
| 92 | filterParameters["root"] = GetSerializableObject(this.root); |
| 93 | filterParameters["filters"] = this.filters; |
| 94 | parameters["relative"] = filterParameters; |
| 95 | object? rawElements = js.ExecuteScript(wrappedAtom, parameters); |
| 96 | |
| 97 | if (rawElements is ReadOnlyCollection<IWebElement> elements) |
| 98 | { |
| 99 | return elements; |
| 100 | } |
| 101 | |
| 102 | // De-serializer quirk - if the response is empty then the de-serializer will not know we're getting back elements |
| 103 | // We will have a ReadOnlyCollection<object> |
| 104 | |
| 105 | if (rawElements is ReadOnlyCollection<object> elementsObj) |
| 106 | { |
| 107 | if (elementsObj.Count == 0) |
| 108 | { |
| 109 | #if NET8_0_OR_GREATER |
| 110 | return ReadOnlyCollection<IWebElement>.Empty; |
| 111 | #else |
| 112 | return new List<IWebElement>().AsReadOnly(); |
| 113 | #endif |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | throw new WebDriverException($"Could not de-serialize element list response{Environment.NewLine}{rawElements}"); |
| 118 | } |
| 119 | |
| 120 | /// <summary> |
| 121 | /// Locates an element above the specified element. |
nothing calls this directly
no test coverage detected