# JQuerySelector

`JQuerySelector` class is used for finding DOM elements using jQuery selector mechanism. jQuery uses Sizzle as its search engine (which you can use directly by using `SizzleSelector`), however it also contains additional features like traversing methods that Sizzle itself does not support.

## Constuctor

Initializes a new instance of the `JQuerySelector` class.

{% tabs %}
{% tab title="C#" %}
The basic constructor with the selector string as an argument.

```csharp
var selector = new JQuerySelector(":text");
```

{% endtab %}

{% tab title="C#" %}
The constructor with the nested `JQuerySelector` context will invoke the nested context selector first, and on the results of this selector will perform the new query further narrowing the results.

```csharp
var selector = new JQuerySelector(":text", By.JQuerySelector("div.myClass"));
```

{% endtab %}

{% tab title="C#" %}
The constructor with the alternative jQuery variable name specified. This can be useful in cases where the variable name conflicts with other libraries.

```csharp
var selector = new JQuerySelector(":text", variable: "myJQuery"));
```

{% endtab %}
{% endtabs %}

## Add

{% tabs %}
{% tab title="C#" %}
Adds elements to the set of matched elements.

```csharp
var selector = new JQuerySelector("div").Add("p");
```

{% endtab %}

{% tab title="C#" %}
Adds elements to the set of matched elements.

```csharp
var selector = new JQuerySelector("div").Add("p", new JQuerySelector("footer"));
```

{% endtab %}
{% endtabs %}

## AddBack

Add the previous set of elements on the stack to the current set, optionally filtered by a selector.

```csharp
var selector = new JQuerySelector("div").Find("span").AddBack();
```

## AndSelf

Add the previous set of elements on the stack to the current set.

```csharp
var selector = new JQuerySelector("div").Find("span").AndSelf();
```

## Children

Get the children of each element in the set of matched elements, optionally filtered by a selector.

```csharp
var selector = new JQuerySelector("div").Children("span");
```

## Closest

For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.

```csharp
var selector = new JQuerySelector("div").Closest("article");
```

## Contents

Get the children of each element in the set of matched elements, including text and comment nodes.

```csharp
var selector = new JQuerySelector("div").Contents();
```

## End

End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.

```csharp
var selector = new JQuerySelector("div").Filter(".class").End();
```

## Eq

Reduce the set of matched elements to the one at the specified index.

```csharp
var selector = new JQuerySelector("div").Eq(3);
```

## Filter

Reduce the set of matched elements to those that match the selector or pass the function's test.

```csharp
var selector = new JQuerySelector("div").Filter(".class");
```

## Find

Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.

```csharp
var selector = new JQuerySelector("div").Find(".class");
```

## First

Reduce the set of matched elements to the first in the set.

```csharp
var selector = new JQuerySelector("div").First();
```

## Has

Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.

```csharp
var selector = new JQuerySelector("div").Has("span");
```

## Is

Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.

```csharp
var selector = new JQuerySelector("div").Is(".class");
```

## Last

Reduce the set of matched elements to the final one in the set.

```csharp
var selector = new JQuerySelector("div").Last();
```

## Next

Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.

```csharp
var selector = new JQuerySelector("div").Next("div");
```

## NextAll

Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.

```csharp
var selector = new JQuerySelector("div").NextAll("div");
```

## NextUntil

Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed.

```csharp
var selector = new JQuerySelector("div").NextUntil(".class");
```

## Not

Remove elements from the set of matched elements.

```csharp
var selector = new JQuerySelector("div").Not(".class");
```

## OffsetParent

Get the closest ancestor element that is positioned.

```csharp
var selector = new JQuerySelector("div").OffsetParent();
```

## Parent

Get the parent of each element in the current set of matched elements, optionally filtered by a selector.

```csharp
var selector = new JQuerySelector("div").Parent();
```

## Parents

Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.

```csharp
var selector = new JQuerySelector("div").Parents();
```

## ParentsUntil

Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object.

```csharp
var selector = new JQuerySelector("div").ParentsUntil("body");
```

## Prev

Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.

```csharp
var selector = new JQuerySelector("div").Prev("div");
```

## PrevAll

Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.

```csharp
var selector = new JQuerySelector("div").PrevAll("div");
```

## PrevUntil

Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object.

```csharp
var selector = new JQuerySelector("div").PrevUntil(".class");
```

## Siblings

Get the siblings of each element in the set of matched elements, optionally filtered by a selector.

```csharp
var selector = new JQuerySelector("div").Siblings();
```

## Slice

Reduce the set of matched elements to a subset specified by a range of indexes.

```csharp
var selector = new JQuerySelector("div").Slice(1, 3);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://softlr.gitbook.io/selenium-webdriver-extensions/api/jqueryselector.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
