Selenium WebDriver Tutorial #2 - Selenium WebDriver Architecture
Summary
TLDREste tutorial de Selenium WebDriver explica la arquitectura de Selenium, crucial para comprender cómo se desarrollan y ejecutan los scripts de automatización. Se describe cómo las bibliotecas de cliente de Selenium permiten escribir código en múltiples lenguajes de programación y cómo estos se traducen al protocolo JSON para interactuar con el navegador a través del WebDriver. Se ilustra con ejemplos cómo se ejecutan comandos en el navegador, y se menciona la importancia de descargar y configurar los controladores de navegador compatibles. Finalmente, se toca el tema de la API REST de Selenium WebDriver y se guía al espectador hacia la documentación oficial para un entendimiento más profundo.
Takeaways
- 🧩 Comprender la arquitectura de Selenium es crucial para comprender cómo se ejecutan y configuran los scripts de automatización en diferentes entornos de desarrollo.
- 🌐 Selenium soporta múltiples lenguajes de programación, como Java, Python, Ruby, C# y JavaScript, lo que permite a los usuarios escribir scripts en el lenguaje de su elección.
- 💻 La librería cliente de Selenium es esencial para interpretar el código escrito en los distintos lenguajes de programación y convertirlo en un formato que el WebDriver pueda entender.
- 🔄 El JSON Wire Protocol actúa como un puente entre el código escrito por el usuario y el WebDriver, permitiendo la comunicación bidireccional entre ellos.
- 🌐 Los controladores del navegador, como ChromeDriver, GeckoDriver y SafariDriver, son necesarios para que Selenium interactúe con los navegadores reales y ejecute las acciones definidas en los scripts.
- 🔍 La comunicación entre el WebDriver y los controladores del navegador se realiza a través de solicitudes HTTP, que pueden ser GET o POST, dependiendo de la operación que se esté realizando.
- 🛠️ Para comenzar con Selenium, es necesario descargar e instalar los controladores del navegador correspondientes al navegador en el que se deseen ejecutar los tests.
- 🔗 El Selenium WebDriver es en realidad una API REST que maneja las solicitudes y respuestas en formato JSON, permitiendo la interacción con los elementos del navegador.
- 📚 La especificación W3 WebDriver ofrece detalles sobre cómo se implementan los métodos y acciones del WebDriver, lo que puede ser útil para aquellos interesados en los aspectos técnicos internos.
- 💼 Conocer la arquitectura de alto nivel de Selenium es beneficioso para los entrevistas y para entender el flujo general de la automatización de pruebas sin profundizar en los detalles técnicos.
Q & A
¿Qué es Selenium y por qué es importante entender su arquitectura?
-Selenium es una herramienta de automatización de pruebas web que permite la interacción con diferentes navegadores a través de diferentes lenguajes de programación. Es importante entender su arquitectura porque ayuda a comprender cómo se configura el desarrollo y cómo los scripts interactúan con los navegadores, lo que es crucial para cualquier marco de automatización.
¿Qué es la librería cliente de Selenium y qué función cumple?
-La librería cliente de Selenium es un conjunto de herramientas que permite escribir código en varios lenguajes de programación soportados por Selenium, como Java, Python, Ruby, C# y JavaScript. Ayuda a interpretar el código escrito y a traducirlo al formato JSON para su posterior envío al WebDriver a través del protocolo JSON Wire.
¿Qué es el protocolo JSON Wire y cómo se relaciona con Selenium?
-El protocolo JSON Wire es una capa de comunicación que permite que los comandos escritos en lenguajes de programación sean enviados al WebDriver en formato JSON a través de HTTP. Es fundamental en Selenium para la comunicación entre el código de automatización y los controladores del navegador.
¿Cuál es el papel del WebDriver en la arquitectura de Selenium?
-El WebDriver en la arquitectura de Selenium actúa como un intermediario entre la librería cliente y el navegador real. Recibe los comandos en formato JSON, los traduce y los ejecuta en el navegador, devolviendo los resultados de las acciones realizadas.
¿Qué es un controlador de navegador y cómo se relaciona con Selenium?
-Un controlador de navegador es un componente específico para cada navegador (como ChromeDriver para Chrome, GeckoDriver para Firefox, etc.) que permite a Selenium interactuar con el navegador. Es necesario descargar y configurar el controlador correspondiente al navegador que se desea automatizar.
¿Cómo se ejecuta un script de Selenium y qué sucede si encuentra un error?
-Un script de Selenium se ejecuta iniciando el navegador, ejecutando las acciones definidas en el script (como buscar texto en Google) y respondiendo según el éxito de la acción. Si se encuentra un error, como un elemento no encontrado, el controlador del navegador devuelve el error al WebDriver, que a su vez lo envía al IDE en formato JSON.
¿Qué es la API de Selenium WebDriver y cómo se relaciona con la automatización de pruebas?
-La API de Selenium WebDriver es una interfaz de programación que permite a los desarrolladores escribir código para automatizar las pruebas en un navegador web. Es una REST API que maneja las solicitudes y respuestas en formato JSON, facilitando la interacción con los elementos del navegador.
¿Dónde puedo encontrar más detalles sobre la especificación de la API de Selenium WebDriver?
-Puedes encontrar más detalles sobre la especificación de la API de Selenium WebDriver en la documentación oficial de Selenium, donde se detallan las diferentes acciones y métodos disponibles, como encontrar elementos o realizar acciones en ellos.
¿Cómo se configura el entorno de desarrollo para comenzar a escribir pruebas con Selenium?
-Para configurar el entorno de desarrollo, es necesario descargar la librería cliente de Selenium correspondiente al lenguaje de programación elegido, descargar y configurar el controlador del navegador y, opcionalmente, ajustar la configuración de Selenium WebDriver según las necesidades específicas del proyecto.
¿Qué tipo de preguntas sobre la arquitectura de Selenium se pueden esperar en una entrevista?
-En una entrevista, se pueden esperar preguntas sobre cómo funciona la comunicación entre la librería cliente, el WebDriver y el navegador, el papel del protocolo JSON Wire, cómo se ejecutan y manejan los errores en los scripts de Selenium, y detalles sobre la configuración y uso de la API de Selenium WebDriver.
Outlines
😀 Introducción a la Arquitectura de Selenium
Este tutorial se centra en la arquitectura de Selenium, explicando su importancia para comprender cómo se desarrolla y ejecuta un script de automatización. Se menciona que Selenium soporta múltiples lenguajes de programación y se utiliza la librería cliente de Selenium para escribir y interpretar el código. Se describe el proceso de cómo el código se convierte en formato JSON y se envía a través del protocolo JSON Wire a los controladores del navegador. Se ilustra con un ejemplo práctico de cómo se ejecuta un script en el navegador Chrome, incluyendo la interacción bidireccional entre el código, el WebDriver y el navegador real.
🔧 Configuración y Detalles Técnicos de Selenium WebDriver
En este párrafo, se profundiza en la configuración de Selenium, incluyendo la necesidad de descargar y configurar controladores de navegador según el navegador en el que se deseen ejecutar las pruebas. Se mencionan los diferentes controladores disponibles para navegadores como Firefox, Safari y Chrome, y se destaca la responsabilidad de diferentes organizaciones en el soporte de estos. Además, se habla sobre la implementación de Selenium WebDriver como una API REST, donde los comandos de código se convierten en solicitudes HTTP y se envían en formato JSON. Se sugiere explorar la documentación para comprender mejor la especificación W3C de WebDriver y sus métodos de acción.
📚 Conclusión y Recursos para Aprendizaje Avanzado
El tutorial concluye con una breve mención de la especificación W3C para WebDriver, que detalla las acciones disponibles para los elementos y los métodos GET y POST utilizados en la implementación. Se alienta a los aprendices interesados en la implementación interna de WebDriver a estudiar la documentación para obtener más detalles. Para aquellos que buscan ser tester de automatización sin profundizar en los detalles técnicos, se recomienda enfocarse en la arquitectura de alto nivel, que es útil para respuestas en entrevistas. El presentador agradece la atención y ofrece un resumen de los conceptos clave tratados en el tutorial.
Mindmap
Keywords
💡Selenium
💡Arquitectura de Selenium
💡Biblioteca de cliente de Selenium
💡JSON Wire Protocol
💡WebDriver
💡Navegadores y controladores de navegador
💡IDE (Entorno de desarrollo integrado)
💡REST API
💡Elementos del navegador
💡Errores en la automatización
Highlights
Tutorial sobre la arquitectura de Selenium WebDriver.
Importancia de comprender la arquitectura de Selenium para la configuración y escritura de scripts de automatización.
Selenium admite múltiples lenguajes de programación como Java, Python, Ruby, C# y JavaScript.
La librería cliente de Selenium ayuda a escribir código en diferentes lenguajes de programación.
El código escrito se convierte en formato JSON y se transfiere a través del protocolo JSON Wire.
El protocolo JSON Wire actúa como un puente entre el código y los controladores del navegador.
Los controladores del navegador, como ChromeDriver, interactúan con el navegador real para ejecutar las acciones definidas en el script.
Las acciones del navegador y los resultados se comunican de vuelta al IDE a través del protocolo JSON Wire.
Ejemplo de un script básico de Selenium para buscar texto en Google.
Si el navegador no encuentra un elemento definido en el script, se devuelve un error.
Los errores se comunican de vuelta al IDE en formato JSON.
Selenium WebDriver es en realidad una API REST.
La documentación proporciona detalles sobre la especificación W3 de WebDriver y sus componentes.
La arquitectura de Selenium es importante para respuestas en entrevistas y comprender cómo funciona la herramienta.
Se recomienda enfocarse en la arquitectura de alto nivel si no se está interesado en los detalles internos de la implementación.
Tutorial concluye con una revisión de la arquitectura de Selenium y agradece a los espectadores.
Transcripts
hello guys welcome to selenium-webdriver
tutorial in this tutorial we are going
to understand about selenium
architecture so the previous tutorial
was all about the selenium introduction
the basics of selenium and now let's
understand the selenium architecture
understanding selenium architecture is
really important because it will help
you to understand how you are going to
set up the development in one meant and
write the script so how your scripts
interact with the browser so this
understanding is really important in any
automation framework or any automation
tool so having a basic understanding of
the architecture helps you a lot in you
know like future in the advanced topics
in learning the tool properly so let's
go ahead and understand the selenium
architecture so here on my screen I have
prepared a diagram for selenium
architecture so if you see in the left
hand side we have the selenium client
library section right so what this
selenium client library is because we
have seen that selenium supports
multiple programming languages like Java
Python Ruby c-sharp JavaScript right so
this client library provided by selenium
is basically helps you to write your
code in any of these programs supported
programming languages in the integrated
development environment so for example
for Java you will use Eclipse for Python
you can use Python for Java you have
other other IDs as well so once you
write your script in any of these
programming languages your selenium
client library helps that code to be
interpreted so basically what happens is
once you write your test case and
trigger your tests that complete
selenium code that you have written in
any programming supported programming
language
for example here let's take an example
of Java that code gets translated or
converted into the JSON format okay and
transferred to the selenium webdriver
through the JSON wire protocol so you if
you see here the JSON wire protocol so
your code whatever you have written gets
converted into the JSON format
through the JSON wire protocol over HTTP
it gets transferred to any of these
browser drivers so here you have the web
driver and then supported you know like
browser drives so for example you try
you are trying to execute your script
that you have written in the Chrome
browser so you will have the
corresponding Chrome browser chrome
driver Chrome browser driver and then
you have the real browser okay so here
you will see these arrows are
bi-directional so what this means is
that the once you run the script it gets
communicated to through the JSON wire
protocol to the selenium webdriver and
the corresponding and the browser driver
which is in this case we are taking an
example of the Chrome browser so chrome
driver and that chrome driver in turn
launches or sense the actions or the
script actions that you have defined to
the real browser okay so it will launch
the real browser it will perform the
action that you have defined in your
script and then based on that action if
the action is successful then it will
respond back whether the action has been
successful and thence to the chrome
browser from the chrome browser again to
the JSON wire protocol over HTTP to your
ID in this case in our case it will be
Eclipse because this is will be using
Java and we'll be using Eclipse as an
integrated development environment for
Java so to give you a brief example say
for example I want to search any text on
komm right so this is the very basic
script that I'll launch the browser I
want to launch google.com in Chrome
browser search a text and see whether
the search has been successful so what
I'll do in the automation steps is I'll
first step will be to launch the browser
and launch and open the URL google comm
then I'll find the text box search text
box I click on that text box and then
I'll enter the text that I want to
search and then click on the search
button and it will give me the results
now in the automation script I'll
perform the same steps so with my
selenium Java client library I'll write
these steps in the programming in the
code and once I'll run this code it this
code will get converted into JSON wire
into JSON format through JSON wire
protocol it will go to the Chrome
browser launch the browser to perform
all these actions if it is not able to
find say for example there is a web
element search text box that you have
defined in your script which is not
which the the the Chrome browser is not
able to the chrome driver is not able to
find in the real browser so in that case
there will be error returned so in that
error scenario the return the error will
be returned to the chrome driver right
and then from chrome driver it will be
returned from in the JSON format with
Jason wire protocol over HTTP to your ID
ok and it will it will be displayed on
your ID as an error so this is briefly
or very quickly to understand the
overview or how the selenium
architecture it is now if you want to
get a lot more detail or want to dig
deeper into you know what exactly how
the selenium webdriver is implement
implemented select selenium webdriver is
actually
rest api okay so if we let's go ahead
and before before understanding that
selenium-webdriver rest api i would like
to show you the browser drivers that we
need to download and configure in our
environment setup right so let me go
back to this website okay and here if
you'll see we'll go to the doc downloads
page right and here you have the
selenium client right so selenium client
every webdriver language bindings so
this is what all the selenium client
library is talking about right so these
client libraries basically so if you
want to write your code or test in Java
you need this client library right you
need to download this now if you want to
run your test case in a different
browser so go to browser section so
gecko driver is implemented for support
by Mozilla right so if you want to run
your test case in the Firefox you need
gecko driver if you need to run test
case in I you need iDrive ER for safari
it is Safari driver and all these are
supported by different organizations who
will see safari supported by Apple or
prized by Oprah software chrome driver
is by the chrome chromium project right
and Edie is by Microsoft so depending on
which browsers you want to run your test
cases you have to download these browser
drivers and configure these right so
this is what we need to configure and
then the selenium webdriver
library so there are multiple
configuration options that are available
so I will show you exactly what all you
need in order to setup your integral
your development environment before you
start writing your first test case in
selenium all right so now when it comes
to understanding what exactly selenium
webdriver so selenium webdriver is
nothing it's an API right it's a REST
API and when you write your test case or
any step in any IDE in language C for
example Java you are writing the step or
code to launch any webpage now what
happens is there is a call behind the
there is a call that happens so your
that that particular line of code is
converted into the JSON format and sent
as a request or a rest get request or
post request so depending on what
operation you are performing so it will
be sent as a post request or get request
and that's what selenium webdriver is
all about so it will be sending that
request and getting the response back
into the JSON format now if you want to
get into the more details of you know
the webdriver API so you can go to the
documentation and in the documentation
here you can you can see the selenium
browser automation project and you can
see w3 webdriver specification if you
click on webdriver specification it will
show you the w3 specification for all
the components of the webdriver right so
for example these are the actions that
are available for the elements so you
can find elements you can find element
from element so all these so if you go
to elements section and scroll down you
will see some get post methods to use
and you can see the find method right
find element so when you say actually
find element use you see actually
internally what happens is it's a post
method and it passes the session ID of
the particular session and finds the
element right the element that you pass
or the locator or the
collision of the element that you pass
so this is more of you know like what
exactly how the webdriver implementation
is done to find elements or find element
from element similarly under the actions
you will see there are a lot of methods
available so this is if you want if you
are more interested into what exactly
the webdriver is how it is implemented
so you can go through this documentation
to learn a lot more about the webdriver
architecture but if you are just
learning to be you know like automation
tester and not worried into too much
detail of the internal working so which
I don't think you will require if you
are just you know doing the automation
script so just stick to the high level
architecture because this architecture
will be asked in many interview
questions so it will help you a lot to
explain how exactly it is implemented so
that's pretty much all about the
selenium architecture hope you liked the
tutorial thank you very much for
watching
Посмотреть больше похожих видео
FormData en javascript - Obteniendo datos de un formulario - Como cuando y porque usarlo - JS
2. Programación en Python | Descargar e instalar Python y PyCharm
Aprende a programar desde cero con PseInt! | Interfaz de PseInt | Parte 3
¿Qué es CODIFICAR, CÓDIGO FUENTE y LENGUAJE MÁQUINA? - Lenguajes de Programación #1
Curso JavaScript desde 0: APIS WEB (API de Validación) - 89
Usar Inspeccionar elemento para los estilos de CSS
5.0 / 5 (0 votes)