> For the complete documentation index, see [llms.txt](https://abi.gitbook.io/net-core/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://abi.gitbook.io/net-core/9.-pruebas-de-integracion/11.1-que-es-selenium/11.1.1-instrucciones-basicas.md).

# 14.2.1 Selenium Instrucciones básicas

Selenium cuenta con las siguientes instrucciones básicas para seleccionar elementos y abrir un nuevo navegador

| Función                                                                                                                                                             | Descripción                                                                 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| `var driver = new ChromeDriver()`                                                                                                                                   | Agrega una nueva instancia de un navegador de Chrome                        |
| <p><code>driver.Navigate()</code></p><p><code>.GoToUrl("<http://www.google.com>");</code></p>                                                                       | Navegas a la página de [www.google.com](http://www.google.com)              |
| `driver.FindElements(By.Name("Nombre"))`                                                                                                                            | Encuentra todos los elementos de la página con el nombre "Nombre"           |
| `driver.FindElement(By.Id("Nombre"))`                                                                                                                               | Encuentra el elemento de la página con el Id "Nombre".                      |
| <p><code>IWebElement input = driver.FindElement(By.Name("Nombre"))</code></p><p><code>input.SendKeys("Juan Peréz");</code></p>                                      | Obtienes el input con el nombre "Nombre" y se teclea el nombre "Juan Peréz" |
| <p><code>var GuardarButton = driver.FindElement</code></p><p><code>(By.CssSelector("btnGuardar"));</code></p><p><code>GuardarButton.Click()</code>;</p>             | Obtienes el elemento con una clase llamada btnGuardar y le das clic         |
| <p><code>new SelectElement</code></p><p><code>(driver.FindElement</code></p><p><code>(By.Name("ComboPais")))</code></p><p><code>.SelectByText("México");</code></p> | Obtienes un combo con el nombre ComboPais y seleccionas la opción México    |
| <p><code>driver.FindElement</code></p><p><code>(By.Id("logo"))</code></p><p><code>.GetAttribute("alt")</code></p>                                                   | Obtienes un elemento con el Id logo y luego su atributo alt                 |
| <p><code>driver.FindElements</code></p><p><code>(By.TagName("button"))</code></p>                                                                                   | Obtienes todos los botones de la página                                     |

Puedes obtener los elementos por:

1. Nombre del elemento
2. Id del elemento
3. Por el nombre del tag&#x20;
4. Por su clase css
5. Por su xPath: Es la ruta para acceder al elemento, puedes seleccionar un elemento con chrome y con el botón derecho del mouse puedes obtener su xPath. Ejemplo:&#x20;

   ```
   //input[@name='usuario']
   ```
6. Por su selector css, por ejemplo: &#x20;

   ```
    input[name='usuario']
   ```

{% hint style="info" %}
Puedes utilizar la extensión de Selenium en Google o Firefox para que te genere el código de como obtener algún elemento
{% endhint %}

Con selenium también puedes tomar screenshots del navegador, el cual se puede subir a Azure Devops


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://abi.gitbook.io/net-core/9.-pruebas-de-integracion/11.1-que-es-selenium/11.1.1-instrucciones-basicas.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
