Selenium is a high quality open source test automation tool for web application testing . El selenio es un alto nivel de calidad de fuente abierta herramienta de automatización de pruebas para las pruebas de aplicaciones web. Selenium runs in Internet Explorer, Mozilla and Firefox on Windows, Linux, and Macintosh, Safari on the Mac, with plans to support Safari on iPhone soon. El selenio se ejecuta en Internet Explorer, Mozilla y Firefox sobre Windows, Linux y Macintosh, Safari en el Mac, con planes de apoyo a Safari iPhone antes. Selenium test scripts are portable, can be run from browsers (using Selenium IDE) or from JUNit or NGUnit (using Selenium RC) etc.. Selenio prueba scripts son portátiles, puede ejecutarse desde los navegadores (usando Selenio IDE) o de JUnit o NGUnit (utilizando selenio RC), etc. For example, test scripts written using Selenium IDE in Firefox on Windows can run on Firefox in Mac or Linux, without changing any code. Por ejemplo, scripts escritos de prueba utilizando selenio IDE en Firefox en Windows puede funcionar en Firefox en Mac o Linux, sin cambiar ningún código. Selenium tests run directly in browsers and so matches the end-user experience closely. Selenio pruebas realizadas directamente en los navegadores y para que coincida con el final de cerca la experiencia del usuario.

There are three variants of Selenium, which can be used in isolation or in combination to create complete automation test suite for your web applications. Hay tres variantes de selenio, que pueden ser utilizados en forma aislada o en combinación para crear completo de automatización de pruebas para su suite de aplicaciones web.

  • Selenium Core - In Selenium Core the tests scripts (written in HTML) and the Selenium Test Runner (written in Javascript) are uploaded to the same web server that hosts the application you are trying to test. Selenio Core - Selenio Core En las pruebas scripts (escrito en HTML) y el selenio Test Runner (escrito en JavaScript) se suben al mismo servidor web que aloja la aplicación que está tratando de probar. It is a simpler form of Selenium, and suitable for non-developers, but it has some inherent limitations. Se trata de una simple forma de selenio, y adecuado para no desarrolladores, pero tiene algunas limitaciones inherentes.

  • Selenium IDE - Selenium IDE is a Firefox plugin, which includes the entire Selenium Core, allows you to record, play back, edit, and debug tests in browser. Selenio IDE - IDE El selenio es un plugin de Firefox, que incluye todo el Selenio Core, le permite grabar, reproducir, editar y depurar las pruebas en el navegador. It provides the simplest introduction to Selenium and is highly recommended for beginners. Proporciona la más simple introducción a Selenio y es altamente recomendado para los principiantes. You can save the tests / test suite created in xml or html format. Puede guardar la prueba o conjunto de pruebas creada en xml o html. However to run them in an automated fashion you need Selenium Remote Control which is described next. Sin embargo, para ejecutar en forma automatizada que necesita Selenio de control remoto que se describe a continuación.

  • Selenium Remote Control - The Selenium Remote Control allows you to develop test cases and test suites in Java (supports JUnit & NGUnit), PHP, Ruby, Python, Perl and even .NET. Selenio control remoto - El Selenio control remoto le permite desarrollar casos de prueba y series de ensayos en Java (JUnit y apoya NGUnit), PHP, Ruby, Python, Perl e incluso. NET. It is the most flexible setup but requires some development knowledge to set up and use. Es la configuración más flexible pero requiere algunos conocimientos sobre desarrollo de configurar y utilizar.

  • Selenium Grid - Selenium Grid allows several Selenium Remote Control servers to be accessed in parallel by Selenium Grid server. Selenio Grid - Grid permite Selenio Selenio varios servidores de control remoto para tener acceso en paralelo de Selenio Grid servidor. This is extremely useful for automated load and stress testing of web applications. Esto es extremadamente útil para la carga automática y pruebas de estrés de aplicaciones web.



Today we will discuss on how you can easily create automatic test scripts using Selenium IDE and convert them to JUnit tests (which uses Selenium Remote Control) which can be added to your JUnit based automatic regression test suite. Hoy vamos a discutir sobre cómo usted puede crear fácilmente secuencias de comandos de prueba automática utilizando selenio IDE y convertir a las pruebas JUnit (que utiliza el selenio control remoto) que puede ser añadido a su JUnit automática basada en conjunto de pruebas de regresión.

How to create a test plan in Selenium IDE ¿Cómo crear un plan de ensayo en Selenio IDE


Creating a test plan in Selenium IDE is very easy, so we will use it to create few simple tests to begin with. La creación de un plan de ensayo en Selenio IDE es muy fácil, así que vamos a utilizar para crear algunas pruebas sencillas para empezar.

  • Install Instale Selenium IDE 0.8.7 Selenio IDE 0.8.7 , a Firefox plugin. , Un plugin de Firefox.

  • After installing Selenium please restart your Firefox browser for the plugin to be activated. Después de instalar el selenio, por favor, reinicie el navegador Firefox para el plugin para ser activado.

  • Now you should see a new added menu item named Selenium IDE under your Firefox Tools menu. Ahora usted debería ver un nuevo elemento de menú añadido llamado selenio IDE bajo su Firefox menú Herramientas.

  • Open / browse the site for which you want to prepare a test case. Abrir / navegar por el sitio para el que desea preparar un caso de prueba.

  • Start Selenium IDE from Firefox Tools->Selenium IDE . Inicio Selenio IDE de Firefox Herramientas-> El selenio IDE.

  • Browse some pages. Navegar algunas páginas.

  • Now click red button to stop recording. Ahora haga clic en un botón rojo para detener la grabación.


At this point you will see Selenium automatically recording your actions. En este punto verá Selenio automáticamente la grabación de sus acciones. Carefully note the commands, target and value. Nota cuidadosamente los comandos, y el valor objetivo. You can create and insert your own commands/ modify or even delete them. Puede crear e insertar sus propios comandos y modificar o incluso borrarlos. We will show some examples below. Se muestran algunos ejemplos a continuación. In the next section we will see how we can modify the generated tests to suit our needs. En la próxima sección veremos cómo podemos modificar los ensayos generados para satisfacer nuestras necesidades.

How to create / modify / delete Selenium commands ¿Cómo crear / modificar / eliminar selenio comandos


The default commands generated by Selenium when you are browsing the page as a normal user should be modified to make the test more robust and to add test cases to it. El valor por defecto comandos generados por Selenio cuando usted está navegando en la página como un usuario normal debería ser modificado para hacer la prueba más sólida y para añadir casos de prueba a la misma.

  • Let's replace all click commands by clickAndWait . click simply clicks the specified link and goes on to execute the next command without waiting. Vamos a sustituir todos los comandos de clic clickAndWait. Clic simplemente hace clic en el vínculo especificado y va a ejecutar el siguiente comando sin esperar. On the other hand clickAndWait waits for the new page to loaded before executing the next command. clickAndWait should be used to make more robust test cases. Por otra parte clickAndWait espera a la nueva página a cargar antes de ejecutar el siguiente comando. ClickAndWait debe utilizarse para hacer más sólido casos de prueba.

  • Insert assertTextNotPresent command after each clickAndWait command to confirm a text must not be present in the browsed page. Inserte assertTextNotPresent comando después de cada comando clickAndWait para confirmar un texto no debe estar presente en la página de búsquedas.

  • Use assertTextPresent command to confirm a text must be present in the browsed page. Use assertTextPresent comando para confirmar un texto debe estar presente en la página de búsquedas.

  • Finally to test your test plan please click green arrow button to play from the begining or to play from start point. Finalmente para poner a prueba su plan de ensayo, por favor haga clic en el botón flecha verde para jugar desde el principio o para jugar desde el principio.

  • Export the test plan as java file by Selenium IDE File->Export Test As->Java - Selenium RC (for example the file name is SeleniumSTSanityTest.java ) Exportar el plan de ensayos como java archivo de Selenio IDE Archivo-> Exportar Test As-> Java - Selenio RC (por ejemplo el nombre del archivo es SeleniumSTSanityTest.java)

  • Then close your Firefox Selenium ID. A continuación, cerrar su ID Firefox Selenio.



How to run above test plan (automatically generated java file from Selenium IDE) in command line? Cómo correr por encima de plan de ensayos (generados automáticamente java archivo de Selenio IDE) en la línea de comandos?

  • Download Descargar Selenium RC Selenio RC .

  • Unzip it under the same directory where SeleniumSTSanityTest.java (exported test plan as java file from Selenium ID) was saved. Descomprimir, en relación con el mismo directorio donde SeleniumSTSanityTest.java (exportado como plan de ensayo java archivo de Selenio ID) se salvó.

  • Install junit. Instalar JUnit.

  • Go to directory where you unzip selenium-remote-control-1.0-beta-1-dist.zip file. Ir al directorio donde se descomprima el selenio-control remoto-1.0-beta-1-dist.zip archivo.

  • Open a terminal and do the steps below- Abra una terminal y hacer los pasos que aparecen a continuación -

    • cd selenium-remote-control-1.0-beta-1/selenium-server-1.0-beta-1 CD selenium-remote-control-1.0-beta-1/selenium-server-1.0-beta-1

    • java -jar selenium-server.jar (to run the server in interactive mode execute java -jar selenium-server.jar -interactive) java-jar-server.jar selenio (para ejecutar el servidor en modo interactivo ejecutar java-jar-selenio server.jar-interactivo)

    • If you get an error like Error: com.thoughtworks.selenium.SeleniumException: ERROR Server Exception: sessionId should not be null; has this session been started yet? then ensure that the browser is in the PATH before running the server. Si obtiene un error como Error: com.thoughtworks.selenium.SeleniumException: ERROR Server Excepción: sessionId no debe ser nula; este período de sesiones ha sido iniciado todavía? Luego asegurar que el navegador está en el PATH antes de ejecutar el servidor. For example, you want to run the test in Firefox. Por ejemplo, usted desea ejecutar la prueba en Firefox. Then you should do next two steps. Entonces usted debe hacer dos próximos pasos.

    • locate firefox-bin (for example it returns /usr/lib/firefox-1.5.0.12/firefox-bin) localizar firefox-bin (por ejemplo, devuelve / usr/lib/firefox-1.5.0.12/firefox-bin)

    • export PATH=$PATH:/usr/lib/firefox-1.5.0.12/firefox-bin; export PATH = $ PATH: / usr/lib/firefox-1.5.0.12/firefox-bin;
      Note: There is an alternative way to fix above error (browser is not in path). Nota: Hay una forma alternativa de fijar por encima de error (navegador no está en camino). Simply replace chrome with browser PATH in SeleniumSTSanityTest.java file. Basta con sustituir el cromo con navegador SeleniumSTSanityTest.java PATH en el archivo. For example: Por ejemplo:
      line línea
      setUp("http://blog.taragana.com", "*chrome"); setup ( "http://blog.taragana.com", "* cromo");
      becomes se convierte en
      setUp("http://blog.taragana.com", "*firefox /usr/lib/firefox-1.5.0.12/firefox-bin"); setup ( "http://blog.taragana.com", "* firefox / usr/lib/firefox-1.5.0.12/firefox-bin");
      in SeleniumSTSanityTest.java . en SeleniumSTSanityTest.java.
      To run the test in opera browser replace chrome with opera . Para ejecutar la prueba en el navegador Opera sustituir cromo con la ópera.


    Now the selenium server is running and you have to run the Java client located in selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1. Ahora, el selenio servidor está en ejecución y debe ejecutar el cliente Java ubicado en selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1.

  • Open another terminal. Abrir otra terminal.

    • export CLASSPATH=.:selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1/selenium-java-client-driver.jar:/usr/share/java/junit.jar exportación CLASSPATH =.: selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1/selenium-java-client-driver.jar: / usr / share / java / JUnit. jar

    • javac SeleniumSTSanityTest.java javac SeleniumSTSanityTest.java

    • java SeleniumSTSanityTest Java SeleniumSTSanityTest




The automatically generated java file SeleniumSTSanityTest.java is likely to have some defects. La genera automáticamente el archivo java SeleniumSTSanityTest.java es probable que tenga algunos defectos. Fix it by comparing with the example below: Fix que comparando con el siguiente ejemplo:




import com.thoughtworks.selenium.*; importación com.thoughtworks.selenium .*;
import junit.framework.*; importación junit.framework .*;
import java.util.regex.Pattern; java.util.regex.Pattern importación;

public class SeleniumSTSanityTest extends SeleneseTestCase { SeleniumSTSanityTest público de clase se extiende SeleneseTestCase (
public void setUp() throws Exception { public void setup () (lanza Excepción
setUp("http://blog.taragana.com", "*chrome"); // to run the test in opera replace chrome with opera setup ( "http://blog.taragana.com", "* cromo"); / / a correr la prueba en la ópera sustituir cromo con la ópera
} )
public void testSimpleThoughts() throws Exception { public void testSimpleThoughts () (lanza Excepción
selenium.open(""); selenium.open ("");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "error de base de datos de WordPress: ["));
assertTrue(selenium.isTextPresent("2003-2008")); assertTrue (selenium.isTextPresent ( "2003-2008"));
selenium.open("/index.php/category/programming/java"); selenium.open ( "/ index.php / categoría / programación / java");
selenium.waitForPageToLoad("30000"); selenium.waitForPageToLoad ( "30000");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "error de base de datos de WordPress: ["));
assertTrue(selenium.isTextPresent("2003-2008")); assertTrue (selenium.isTextPresent ( "2003-2008"));
selenium.click("//img[@alt='Übersetzen Sie zum Deutsch/German']"); selenium.click ( "/ / img [@ alt = 'zum Übersetzen Sie Deutsch / Alemán']");
selenium.waitForPageToLoad("30000"); selenium.waitForPageToLoad ( "30000");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "error de base de datos de WordPress: ["));
assertTrue(selenium.isTextPresent("2003-")); assertTrue (selenium.isTextPresent ( "2003 -"));
selenium.click("//img[@alt='Přeložit do Čech/Czech']"); selenium.click ( "/ / img [@ alt = 'Přeložit hacer Čech / checo']");
selenium.waitForPageToLoad("60000"); selenium.waitForPageToLoad ( "60000");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "error de base de datos de WordPress: ["));
assertTrue(selenium.isTextPresent("2003")); assertTrue (selenium.isTextPresent ( "2003"));
} )

public static Test suite() { public static Test suite () (
return new TestSuite(SeleniumSTSanityTest.class); volver nuevo testsuite (SeleniumSTSanityTest.class);
} )

public static void main(String args[]) { public static void main (String args []) (
junit.textui.TestRunner.run(suite()); junit.textui.TestRunner.run (suite ());
} )
} )



Let me know if you have any comments / suggestions on how we can improve this tutorial. Quiero saber si usted tiene algún comentario o sugerencias sobre cómo podemos mejorar este tutorial.