Vote Voter 8 8
5 Minute Guide To Selenium IDE and Selenium Remote Control (Java) Test Tools 5 Minute Guide to IDE sélénium et le sélénium Remote Control (Java) d'outils de test
Angsuman Chakraborty Angsuman Chakraborty
July 1st, 2008 1er juillet, 2008 Selenium is a high quality open source test automation tool for web application testing . Le sélénium est un de haute qualité open source Outil d'automatisation de tests pour les essais d'applications 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. Sélénium fonctionne dans Internet Explorer, Mozilla et Firefox sous Windows, Linux et Macintosh, Safari sur Mac, avec des projets d'appui Safari sur l'iPhone bientôt. Selenium test scripts are portable, can be run from browsers (using Selenium IDE) or from JUNit or NGUnit (using Selenium RC) etc.. Le sélénium sont des scripts de test portatif peut être utilisé par les navigateurs (en utilisant Sélénium IDE) ou de JUnit ou NGUnit (à l'aide de sélénium 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. Par exemple, des scripts de test écrits en utilisant Sélénium IDE dans Firefox sous Windows peut fonctionner sur Firefox sous Mac ou Linux, sans changer le code. Selenium tests run directly in browsers and so matches the end-user experience closely. Sélénium essais vont directement dans les navigateurs et correspond à la fin de près l'expérience de l'utilisateur.
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. Il existe trois variantes de sélénium, qui peuvent être utilisés isolément ou en combinaison pour créer l'automatisation complète suite de test pour vos applications 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. Aujourd'hui, nous allons discuter sur la façon dont vous pouvez facilement créer des scripts de test automatique utilisant Sélénium IDE et les convertir en de tests JUnit (qui utilise Sélénium Remote Control) qui peut être ajouté à votre JUnit en fonction automatique suite de tests de régression.
Creating a test plan in Selenium IDE is very easy, so we will use it to create few simple tests to begin with. Création d'un plan de test en sélénium IDE est très simple, nous allons l'utiliser pour créer quelques tests simples pour commencer.
At this point you will see Selenium automatically recording your actions. À ce stade, vous verrez automatiquement l'enregistrement Sélénium vos actions. Carefully note the commands, target and value. Soigneusement note les commandes, et la valeur cible. You can create and insert your own commands/ modify or even delete them. Vous pouvez créer et ajouter vos propres commandes ou même modifier ou les supprimer. We will show some examples below. Nous montrerons quelques exemples ci-dessous. In the next section we will see how we can modify the generated tests to suit our needs. Dans la section suivante, nous allons voir comment nous pouvons modifier les tests générés en fonction de nos besoins.
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. Les commandes par défaut généré par Sélénium lorsque vous naviguez sur la page comme un utilisateur normal devrait être modifié pour rendre le test plus robuste et d'ajouter les cas de test à celui-ci.
How to run above test plan (automatically generated java file from Selenium IDE) in command line? Comment exploiter au-dessus de plan de test (généré automatiquement le fichier java de sélénium IDE) en ligne de commande?
The automatically generated java file SeleniumSTSanityTest.java is likely to have some defects. La généré automatiquement le fichier java SeleniumSTSanityTest.java est susceptible d'avoir certains défauts. Fix it by comparing with the example below: Correction par comparaison avec l'exemple ci-dessous:
Let me know if you have any comments / suggestions on how we can improve this tutorial. Permettez-moi savoir si vous avez des commentaires / suggestions sur la façon dont nous pouvons améliorer ce tutoriel.
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. Il existe trois variantes de sélénium, qui peuvent être utilisés isolément ou en combinaison pour créer l'automatisation complète suite de test pour vos applications 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. Sélénium Core - En Sélénium les tests de base de scripts (écrit en HTML) et le lanceur de tests en Sélénium (écrit en Javascript) sont envoyées sur le même serveur Web qui héberge l'application que vous essayez de tester. It is a simpler form of Selenium, and suitable for non-developers, but it has some inherent limitations. Il est une forme de sélénium, et pour non-développeurs, mais il a certaines limites inhérentes.
- 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. Selenium IDE - Selenium IDE est un plugin Firefox, qui comprend l'ensemble de base de sélénium, vous permet d'enregistrer, de lire, modifier et déboguer des tests dans le navigateur. It provides the simplest introduction to Selenium and is highly recommended for beginners. Il fournit la plus simple introduction à sélénium et est hautement recommandé pour les débutants. You can save the tests / test suite created in xml or html format. Vous pouvez enregistrer les tests / suite de test créé en xml ou format html. However to run them in an automated fashion you need Selenium Remote Control which is described next. Toutefois, pour les exécuter dans un mode automatique, vous devez Sélénium Remote Control qui est décrit prochain.
- 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. Sélénium Remote Control - Le sélénium Remote Control vous permet de développer des scénarios de test et des suites de tests en Java (JUnit et soutient NGUnit), PHP, Ruby, Python, Perl et même. NET. It is the most flexible setup but requires some development knowledge to set up and use. Il est le plus souple de configuration, mais exige une certaine connaissance du développement à installer et à utiliser.
- Selenium Grid - Selenium Grid allows several Selenium Remote Control servers to be accessed in parallel by Selenium Grid server. Sélénium Grid - Sélénium Grid sélénium permet à plusieurs serveurs de contrôle à distance d'accéder en parallèle par Sélénium Grid serveur. This is extremely useful for automated load and stress testing of web applications. C'est extrêmement utile pour automatiser la charge et le stress tests des applications 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. Aujourd'hui, nous allons discuter sur la façon dont vous pouvez facilement créer des scripts de test automatique utilisant Sélénium IDE et les convertir en de tests JUnit (qui utilise Sélénium Remote Control) qui peut être ajouté à votre JUnit en fonction automatique suite de tests de régression.
How to create a test plan in Selenium IDE Comment créer un plan de test en sélénium IDE
Creating a test plan in Selenium IDE is very easy, so we will use it to create few simple tests to begin with. Création d'un plan de test en sélénium IDE est très simple, nous allons l'utiliser pour créer quelques tests simples pour commencer.
- Install Installez Selenium IDE 0.8.7 Selenium IDE 0.8.7 , a Firefox plugin. , Un plugin Firefox.
- After installing Selenium please restart your Firefox browser for the plugin to be activated. Après l'installation Sélénium s’il vous plaît redémarrer votre navigateur Firefox pour le plugin à être activé.
- Now you should see a new added menu item named Selenium IDE under your Firefox Tools menu. Maintenant, vous devriez voir un nouvel élément de menu ajouté le nom de sélénium IDE sous votre menu Outils de Firefox.
- Open / browse the site for which you want to prepare a test case. Ouvert / naviguer sur le site pour lequel vous souhaitez préparer un scénario de test.
- Start Selenium IDE from Firefox Tools->Selenium IDE . Début Sélénium IDE de Firefox Outils-> IDE sélénium.
- Browse some pages. Parcourir quelques pages.
- Now click red button to stop recording. Maintenant cliquez sur le bouton rouge pour arrêter l'enregistrement.
At this point you will see Selenium automatically recording your actions. À ce stade, vous verrez automatiquement l'enregistrement Sélénium vos actions. Carefully note the commands, target and value. Soigneusement note les commandes, et la valeur cible. You can create and insert your own commands/ modify or even delete them. Vous pouvez créer et ajouter vos propres commandes ou même modifier ou les supprimer. We will show some examples below. Nous montrerons quelques exemples ci-dessous. In the next section we will see how we can modify the generated tests to suit our needs. Dans la section suivante, nous allons voir comment nous pouvons modifier les tests générés en fonction de nos besoins.
How to create / modify / delete Selenium commands Comment créer / modifier / supprimer des commandes Sélénium
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. Les commandes par défaut généré par Sélénium lorsque vous naviguez sur la page comme un utilisateur normal devrait être modifié pour rendre le test plus robuste et d'ajouter les cas de test à celui-ci.
- Let's replace all click commands by clickAndWait . click simply clicks the specified link and goes on to execute the next command without waiting. Nous allons remplacer toutes les commandes par cliquez sur clickAndWait. Cliquez simplement clique sur le lien indiqué et va à exécuter la commande suivante sans attendre. 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. D'autre part clickAndWait attend la nouvelle page de chargement avant d'exécuter la commande suivante. ClickAndWait devraient être utilisés pour rendre plus robuste cas de test.
- Insert assertTextNotPresent command after each clickAndWait command to confirm a text must not be present in the browsed page. Insérer assertTextNotPresent commande clickAndWait après chaque commande pour confirmer un texte ne doivent pas être présents dans le parcouru la page.
- Use assertTextPresent command to confirm a text must be present in the browsed page. Utilisez assertTextPresent commande pour confirmer un texte doit être présent dans le parcouru la page.
- Finally to test your test plan please click green arrow button to play from the begining or to play from start point. Enfin, pour tester votre plan de test s’il vous plaît cliquez sur la flèche verte bouton pour jouer dès le début ou à jouer de point de départ.
- 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 ) Exporter le plan de test Java dossier par Sélénium IDE Fichier-> Exporter-Test Comme> Java - Sélénium RC (par exemple le nom du fichier est SeleniumSTSanityTest.java)
- Then close your Firefox Selenium ID. Ensuite, fermez Firefox Sélénium ID.
How to run above test plan (automatically generated java file from Selenium IDE) in command line? Comment exploiter au-dessus de plan de test (généré automatiquement le fichier java de sélénium IDE) en ligne de commande?
- Download Télécharger Selenium RC Sélénium RC .
- Unzip it under the same directory where SeleniumSTSanityTest.java (exported test plan as java file from Selenium ID) was saved. Décompressez sous le même répertoire que SeleniumSTSanityTest.java (exporté plan d'essai comme fichier java de sélénium ID) a été enregistré.
- Install junit. Installez JUnit.
- Go to directory where you unzip selenium-remote-control-1.0-beta-1-dist.zip file. Aller au répertoire dans lequel vous décompressez le sélénium-remote-control-1.0-beta-1-dist.zip fichier.
- Open a terminal and do the steps below- Ouvrez une fenêtre de terminal et de suivre les étapes ci-dessous -
- 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 sélénium (de lancer le serveur en mode interactif exécuter java-jar-sélénium server.jar-interactif)
- 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 vous obtenez une erreur de ce type d'erreur: com.thoughtworks.selenium.SeleniumException: ERREUR Server Exception: sessionid ne devrait pas être nulle, cette session a été encore commencé? Ensuite veiller à ce que le navigateur est dans le PATH avant de lancer le serveur. For example, you want to run the test in Firefox. Par exemple, vous voulez exécuter l'essai dans Firefox. Then you should do next two steps. Ensuite, vous devez faire deux prochaines étapes.
- locate firefox-bin (for example it returns /usr/lib/firefox-1.5.0.12/firefox-bin) localiser firefox-bin (par exemple, il retourne / 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). Note: Il est une autre façon de corriger des erreurs (navigateur n'est pas en chemin). Simply replace chrome with browser PATH in SeleniumSTSanityTest.java file. Il vous suffit de remplacer le chrome avec navigateur PATH SeleniumSTSanityTest.java fichier. For example: Par exemple:
line ligne
setUp("http://blog.taragana.com", "*chrome"); setUp ( "http://blog.taragana.com", "chrome *");
becomes devient
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 . dans SeleniumSTSanityTest.java.
To run the test in opera browser replace chrome with opera . Pour exécuter le test à l'opéra navigateur remplacer le chrome avec l'opéra.
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. Aujourd'hui, le sélénium serveur est en cours d'exécution et vous devez lancer le client Java situé dans selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1. - Open another terminal. Ouvrir un autre 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 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. pot
- javac SeleniumSTSanityTest.java javac SeleniumSTSanityTest.java
- java SeleniumSTSanityTest Java SeleniumSTSanityTest
The automatically generated java file SeleniumSTSanityTest.java is likely to have some defects. La généré automatiquement le fichier java SeleniumSTSanityTest.java est susceptible d'avoir certains défauts. Fix it by comparing with the example below: Correction par comparaison avec l'exemple ci-dessous:
import com.thoughtworks.selenium.*;com.thoughtworks.selenium importation .*;
import junit.framework.*;importation junit.framework .*;
import java.util.regex.Pattern;java.util.regex.Pattern importation;
public class SeleniumSTSanityTest extends SeleneseTestCase { public class SeleniumSTSanityTest s'étend SeleneseTestCase (
public void setUp() throws Exception { public void setUp () throws Exception (
setUp("http://blog.taragana.com", "*chrome"); // to run the test in opera replace chrome with opera setUp ( "http://blog.taragana.com", "chrome *") / / pour lancer le test à l'opéra remplacer le chrome avec l'opéra
} )
public void testSimpleThoughts() throws Exception { public void testSimpleThoughts () throws Exception (
selenium.open(""); selenium.open ("");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "erreur de base de données de WordPress: ["));
assertTrue(selenium.isTextPresent("2003-2008")); assertTrue (selenium.isTextPresent ( "2003-2008"));
selenium.open("/index.php/category/programming/java"); selenium.open ( "/ index.php / catégorie / programmation / java");
selenium.waitForPageToLoad("30000"); selenium.waitForPageToLoad ( "30000");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "erreur de base de données 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 =" übersetzen Sie zum Deutsch / allemand']");
selenium.waitForPageToLoad("30000"); selenium.waitForPageToLoad ( "30000");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "erreur de base de données 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 ne Čech / tchèque']");
selenium.waitForPageToLoad("60000"); selenium.waitForPageToLoad ( "60000");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "erreur de base de données de WordPress: ["));
assertTrue(selenium.isTextPresent("2003")); assertTrue (selenium.isTextPresent ( "2003"));
} )
public static Test suite() { public static Test suite () (
return new TestSuite(SeleniumSTSanityTest.class); Retour Nouvelle 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. Permettez-moi savoir si vous avez des commentaires / suggestions sur la façon dont nous pouvons améliorer ce tutoriel.
Filed under Classé sous Headline News Headline News , Java Software Logiciel de Java , Pro Blogging Blogging Pro , Web | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | cet article |
Email this Article Envoyer cet article
You may also like to read Vous mai également à lire |




