Vote Voto 8 8
5 Minute Guide To Selenium IDE and Selenium Remote Control (Java) Test Tools 5 minuti di guida di selenio IDE e selenio telecomando (Java) Strumenti di prova
Angsuman Chakraborty Angsuman Chakraborty
July 1st, 2008 1 ° luglio 2008 Selenium is a high quality open source test automation tool for web application testing . Selenio è un alta qualità open source di prova di automazione strumento per applicazione web di test. 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. Selenio viene eseguito in Internet Explorer, Mozilla e Firefox su Windows, Linux e Macintosh, Safari su Mac, con piani di sostegno Safari su iPhone presto. Selenium test scripts are portable, can be run from browsers (using Selenium IDE) or from JUNit or NGUnit (using Selenium RC) etc.. Selenio prova script sono portatili, può essere eseguito da browser (utilizzando Selenio IDE) o da JUnit o NGUnit (utilizzando Selenio RC), ecc. For example, test scripts written using Selenium IDE in Firefox on Windows can run on Firefox in Mac or Linux, without changing any code. Ad esempio, prova script scritti con Selenio IDE in Firefox su Windows è in grado di funzionare su Firefox in Mac o Linux, senza cambiare qualsiasi codice. Selenium tests run directly in browsers and so matches the end-user experience closely. Selenio eseguire test direttamente nel browser e in modo corrisponde l'utente finale esperienza da vicino.
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. Ci sono tre varianti di selenio, che possono essere utilizzati isolatamente o in combinazione per creare l'automazione completa suite di test per il tuo applicazioni 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. Oggi si discuterà su come si può facilmente creare script di test automatico utilizzando Selenio IDE e convertirli in JUnit test (che utilizza Selenio il controllo remoto) che può essere aggiunto al tuo JUnit automatico basato suite di test di regressione.
Creating a test plan in Selenium IDE is very easy, so we will use it to create few simple tests to begin with. La creazione di un programma di test in Selenio IDE è molto facile, così è usato per creare alcune semplici prove per iniziare con.
At this point you will see Selenium automatically recording your actions. A questo punto vedrete Selenio automaticamente la registrazione vostre azioni. Carefully note the commands, target and value. Nota con attenzione i comandi, obiettivo e valore. You can create and insert your own commands/ modify or even delete them. È possibile creare e inserire il tuo comandi / modificare o eliminare anche loro. We will show some examples below. Ci mostrano alcuni esempi qui di seguito. In the next section we will see how we can modify the generated tests to suit our needs. Nella prossima sezione vedremo come si possa modificare il test generate per soddisfare le nostre esigenze.
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. I comandi di default generato da Selenio durante la navigazione la pagina come un normale utente dovrebbe essere modificata per rendere la prova più robusta e di aggiungere casi di prova ad esso.
How to run above test plan (automatically generated java file from Selenium IDE) in command line? Come eseguire test piano di sopra (java generate automaticamente file da Selenio IDE) in linea di comando?
The automatically generated java file SeleniumSTSanityTest.java is likely to have some defects. Generata automaticamente il file java SeleniumSTSanityTest.java può avere alcuni difetti. Fix it by comparing with the example below: Risolvere il problema attraverso il confronto con l'esempio che segue:
Let me know if you have any comments / suggestions on how we can improve this tutorial. Fammi sapere se avete commenti / suggerimenti su come possiamo migliorare questo tutorial.
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. Ci sono tre varianti di selenio, che possono essere utilizzati isolatamente o in combinazione per creare l'automazione completa suite di test per il tuo applicazioni 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 - In Selenio Core le prove di script (scritto in HTML) e il selenio Test Runner (scritto in JavaScript) vengono caricati allo stesso server web che ospita l'applicazione che si sta tentando di prova. It is a simpler form of Selenium, and suitable for non-developers, but it has some inherent limitations. Si tratta di una semplice forma di selenio, e adatti per i non-sviluppatori, ma ha alcune limitazioni inerenti.
- 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 - Selenio IDE è un plugin per Firefox, che comprende l'intero Selenio Core, consente di registrare, riprodurre, modificare, eseguire il debug e test browser. It provides the simplest introduction to Selenium and is highly recommended for beginners. Esso fornisce la più semplice introduzione al selenio ed è altamente consigliato per i principianti. You can save the tests / test suite created in xml or html format. È possibile salvare le prove / suite di test creato in XML o HTML formato. However to run them in an automated fashion you need Selenium Remote Control which is described next. Tuttavia, per eseguire in modo automatico moda avete bisogno di selenio di controllo remoto che è descritto in seguito.
- 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 di controllo remoto - Il Selenio Remote Control ti permette di sviluppare casi di prova e suite di test in Java (supporta JUnit & NGUnit), PHP, Ruby, Python, Perl e anche. NET. It is the most flexible setup but requires some development knowledge to set up and use. E 'il più flessibile l'installazione, ma richiede un po' lo sviluppo di conoscenze da installare e usare.
- Selenium Grid - Selenium Grid allows several Selenium Remote Control servers to be accessed in parallel by Selenium Grid server. Selenio Griglia - Selenio Grid permette più di selenio di controllo remoto a server sono accessibili in parallelo di Selenio Grid server. This is extremely useful for automated load and stress testing of web applications. Ciò è estremamente utile per automatizzato di carico e di stress test delle applicazioni 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. Oggi si discuterà su come si può facilmente creare script di test automatico utilizzando Selenio IDE e convertirli in JUnit test (che utilizza Selenio il controllo remoto) che può essere aggiunto al tuo JUnit automatico basato suite di test di regressione.
How to create a test plan in Selenium IDE Come creare un programma di test in 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 creazione di un programma di test in Selenio IDE è molto facile, così è usato per creare alcune semplici prove per iniziare con.
- Install Installare Selenium IDE 0.8.7 Selenio IDE 0.8.7 , a Firefox plugin. , Un plugin per Firefox.
- After installing Selenium please restart your Firefox browser for the plugin to be activated. Dopo aver installato Selenio si prega di riavviare il browser Firefox per il plugin per essere attivato.
- Now you should see a new added menu item named Selenium IDE under your Firefox Tools menu. Ora si dovrebbe vedere una nuova voce di menu aggiunto il nome di selenio IDE sotto il tuo Firefox dal menu Strumenti.
- Open / browse the site for which you want to prepare a test case. Aperti / navigare il sito per il quale si desidera preparare un banco di prova.
- Start Selenium IDE from Firefox Tools->Selenium IDE . Inizio Selenio IDE da Firefox Strumenti-> IDE Selenio.
- Browse some pages. Sfoglia alcune pagine.
- Now click red button to stop recording. Ora fare clic su pulsante rosso per interrompere la registrazione.
At this point you will see Selenium automatically recording your actions. A questo punto vedrete Selenio automaticamente la registrazione vostre azioni. Carefully note the commands, target and value. Nota con attenzione i comandi, obiettivo e valore. You can create and insert your own commands/ modify or even delete them. È possibile creare e inserire il tuo comandi / modificare o eliminare anche loro. We will show some examples below. Ci mostrano alcuni esempi qui di seguito. In the next section we will see how we can modify the generated tests to suit our needs. Nella prossima sezione vedremo come si possa modificare il test generate per soddisfare le nostre esigenze.
How to create / modify / delete Selenium commands Come creare / modificare / cancellare comandi Selenio
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. I comandi di default generato da Selenio durante la navigazione la pagina come un normale utente dovrebbe essere modificata per rendere la prova più robusta e di aggiungere casi di prova ad esso.
- Let's replace all click commands by clickAndWait . click simply clicks the specified link and goes on to execute the next command without waiting. Let's sostituire tutti i comandi di fare clic su clickAndWait. Semplicemente fare clic su clic sul link specificato e poi di eseguire il comando successivo senza attendere. 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'altra parte clickAndWait attesa per la nuova pagina al caricato prima di eseguire il comando successivo. ClickAndWait dovrebbero essere utilizzati per rendere più robusta prova casi.
- Insert assertTextNotPresent command after each clickAndWait command to confirm a text must not be present in the browsed page. Inserire assertTextNotPresent comando dopo ogni clickAndWait comando per la conferma di un testo non devono essere presenti nella pagina consultata.
- Use assertTextPresent command to confirm a text must be present in the browsed page. Uso assertTextPresent comando per la conferma di un testo deve essere presente nella pagina consultata.
- Finally to test your test plan please click green arrow button to play from the begining or to play from start point. Infine per testare il vostro programma di test si prega di fare clic su pulsante freccia verde per giocare fin dall'inizio o per la riproduzione da punto di partenza.
- 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 ) Esporta il programma di test come file di Java IDE Selenio File-> Esporta prova-> Java - RC Selenio (ad esempio il nome del file è SeleniumSTSanityTest.java)
- Then close your Firefox Selenium ID. Poi chiudere il tuo ID di Firefox Selenio.
How to run above test plan (automatically generated java file from Selenium IDE) in command line? Come eseguire test piano di sopra (java generate automaticamente file da Selenio IDE) in linea di comando?
- Download Scaricare Selenium RC Selenio RC .
- Unzip it under the same directory where SeleniumSTSanityTest.java (exported test plan as java file from Selenium ID) was saved. Decomprimerlo sotto la stessa directory in cui SeleniumSTSanityTest.java (piano di prova esportati come file da java Selenio Id) è stato salvato.
- Install junit. JUnit installare.
- Go to directory where you unzip selenium-remote-control-1.0-beta-1-dist.zip file. Vai alla directory in cui è decomprimere selenio-remote-control-1.0-beta-1-dist.zip file.
- Open a terminal and do the steps below- Aprire un terminale e di procedere con i passaggi sotto -
- 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 selenio-server.jar (per eseguire il server in modalità interattiva eseguire java-jar selenio-server.jar-interattiva)
- 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. Se si ottiene un errore simile Errore: com.thoughtworks.selenium.SeleniumException: Errore Server Eccezione: sessionid non deve essere null; questa sessione è stato avviato ancora? Quindi garantire che il browser sia nel PATH prima di eseguire il server. For example, you want to run the test in Firefox. Per esempio, si desidera eseguire il test in Firefox. Then you should do next two steps. Quindi è necessario fare due passaggi successivi.
- locate firefox-bin (for example it returns /usr/lib/firefox-1.5.0.12/firefox-bin) individuare firefox-bin (ad esempio, restituisce / 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: Ci è un modo alternativo di fissare sopra di errore (browser non è in cammino). Simply replace chrome with browser PATH in SeleniumSTSanityTest.java file. Basta sostituire cromato con browser SeleniumSTSanityTest.java percorso nel file. For example: Per esempio:
line linea
setUp("http://blog.taragana.com", "*chrome"); setup ( "http://blog.taragana.com", "* cromo");
becomes diventa
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 . in SeleniumSTSanityTest.java.
To run the test in opera browser replace chrome with opera . Per eseguire la prova di cui al browser Opera sostituire cromato con Opera.
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. Ora il selenio server è in esecuzione e si dovrebbe eseguire il client Java situato in selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1. - Open another terminal. Aprire un altro terminale.
- 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 esportazione 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. vaso
- javac SeleniumSTSanityTest.java javac SeleniumSTSanityTest.java
- java SeleniumSTSanityTest Java SeleniumSTSanityTest
The automatically generated java file SeleniumSTSanityTest.java is likely to have some defects. Generata automaticamente il file java SeleniumSTSanityTest.java può avere alcuni difetti. Fix it by comparing with the example below: Risolvere il problema attraverso il confronto con l'esempio che segue:
import com.thoughtworks.selenium.*;importazione com.thoughtworks.selenium .*;
import junit.framework.*;importazione junit.framework .*;
import java.util.regex.Pattern;java.util.regex.Pattern importazione;
public class SeleniumSTSanityTest extends SeleneseTestCase { classe pubblica SeleniumSTSanityTest estende SeleneseTestCase (
public void setUp() throws Exception { public void setup () (getta Eccezione
setUp("http://blog.taragana.com", "*chrome"); // to run the test in opera replace chrome with opera setup ( "http://blog.taragana.com", "* cromo"); / / per eseguire la prova in opera sostituire cromato con Opera
} )
public void testSimpleThoughts() throws Exception { public void testSimpleThoughts () (getta Eccezione
selenium.open(""); selenium.open ("");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "banca dati di WordPress errore: ["));
assertTrue(selenium.isTextPresent("2003-2008")); assertTrue (selenium.isTextPresent ( "2003-2008"));
selenium.open("/index.php/category/programming/java"); selenium.open ( "/ / index.php / categoria / programmazione / java");
selenium.waitForPageToLoad("30000"); selenium.waitForPageToLoad ( "30000");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "banca dati di WordPress errore: ["));
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 / tedesco']");
selenium.waitForPageToLoad("30000"); selenium.waitForPageToLoad ( "30000");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "banca dati di WordPress errore: ["));
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 do Čech / ceca']");
selenium.waitForPageToLoad("60000"); selenium.waitForPageToLoad ( "60000");
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertFalse (selenium.isTextPresent ( "banca dati di WordPress errore: ["));
assertTrue(selenium.isTextPresent("2003")); assertTrue (selenium.isTextPresent ( "2003"));
} )
public static Test suite() { public static Test suite () (
return new TestSuite(SeleniumSTSanityTest.class); ritorno nuovo 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. Fammi sapere se avete commenti / suggerimenti su come possiamo migliorare questo tutorial.
Filed under Elencato sotto Headline News Headline News , Java Software Software Java , Pro Blogging Pro Blogging , Web | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | questo articolo |
Email this Article Invia questo articolo
You may also like to read Si può anche leggere come |




