SlideShare uma empresa Scribd logo
1 de 3
Baixar para ler offline
Dalton Valadares – Universidade Federal de Campina Grande
Embedded Systems and Pervasive Computing Lab (Embedded)
How to configure Selenium WebDriver to run with Eclipse programming
in Java
-Download the latest version of Selenium WebDriver Java client driver: http://selenium-
release.storage.googleapis.com/2.40/selenium-java-2.40.0.zip (Currently, I am using the 2.39.0
version, but the 2.40.0 is already available). If you will use another programming language, you
must download the corresponding driver for it (C#, Python, Ruby);
-Extract the content of the selenium-java-2.40.0.zip in a selected folder;
-Open Eclipse in your project or create a new one;
-Add the Selenium JARs to your project:
*Right click on your project's name;
*'Properties' --> 'Java Build Path';
*Click on 'Add External JARs' button;
*Select the two JARs in your Selenium folder (selenium-java-2.39.0-srcs.jar and selenium-
java-2.39.0.jar) and click open;
*Click on 'Add External JARs' button again;
*Open the libs folder which is inside the Selenium folder;
*Select all the JARs inside libs folder and click open;
-Now, the Eclipse is configured to run Selenium WebDriver tests.
Using Chrome and Internet Explorer to run tests with Selenium
-If you will not use the Firefox browser to run your tests, for each browser, it is necessary to
have its respective driver;
-Download the latest version of each in the following links:
*Chrome driver - http://chromedriver.storage.googleapis.com/index.html?path=2.9/
*Internet Explorer driver - http://selenium-
release.storage.googleapis.com/index.html?path=2.40/
-Put them in your PATH (the path to the executable files in your Environment Variables);
-Test with some code like the below one:
public class TestRMS{
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver",
"C:UsersdaltonDocumentsRMSchromedriver.exe");
System.setProperty("webdriver.ie.driver",
"C:UsersdaltonDocumentsRMSIEDriverServer.exe");
WebDriver chromeDriver = new ChromeDriver();
executeTest(chromeDriver);
chromedriver.close();
DesiredCapabilities capabilities =
DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKIN
ESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver ieDriver = new InternetExplorerDriver(capabilities);
executeTest(ieDriver);
ieDriver.close();
}
private static void executeTest(WebDriver driver) throws
InterruptedException {
driver.get("http://www.google.com");
driver.findElement(By.id("gbqfq")).clear();
driver.findElement(By.id("gbqfq")).sendKeys("Selenium
Webdriver");
System.out.println(driver.getCurrentUrl() + " " +
driver.getTitle());
driver.findElement(By.cssSelector("em")).click();
System.out.println(driver.getCurrentUrl() + " " +
driver.getTitle());
}
}
-If you have problem executing the test with Internet Explorer driver, maybe you should try to
change the Protected Zone in the browser (Protected Mode must be set to the same value,
enabled or disabled, for all zones). Option found in the Advanced tab of the Internet Options
dialog.
Accelerating your tests creation
-For make the process of test creation faster, install the Firefox Selenium Plugin (Selenium
IDE): http://release.seleniumhq.org/selenium-ide/2.5.0/selenium-ide-2.5.0.xpi (let the Firefox
install this plugin);
-With the Selenium IDE installed on Firefox, open it, clicking in Tools --> Selenium IDE;
-The Selenium IDE will open and you can record some commands with it, clicking in the red ball
in right upper corner or clicking the right option in Menu Actions;
-After you record some actions of your test, you must to import your script to run with other
browsers. To do this, click on Menu File --> Export Test As... --> Java / JUnit4 / WebDriver (here
you can choose any other type of file, with a different programming language, for example);
-This way, you can edit your test in Eclipse, for example, and run your tests with other
browsers.
Running tests in a remote browser (remote machine)
-To run tests in a remote browser, you have to download the Selenium Grid in the remote
machine: http://selenium-release.storage.googleapis.com/2.40/selenium-server-standalone-
2.40.0.jar (this link is for 2.40.0 version)
-In a command prompt/terminar, run the following command: java -jar ./selenium-server-
standalone-2.40.0.jar -Dwebdriver.chrome.driver='/your/path/to/chromedriver.exe' (if you
will use other browser, like IE, you must to change this parameter/path at the command);
-In your code, to run the test(s) remotely, put code like the below:
DesiredCapabilities capability = DesiredCapabilities.chrome(); //If
you want to change the browser, change the capability here...
capability.setPlatform(Platform.WINDOWS);
//setPlatform(Platform.LINUX);
capability.setVersion("10");
try {
driver = new RemoteWebDriver(new
URL("http://your.remote.IP.Address:4444/wd/hub"), capability); //put your
remote IP here
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-Run your tests.
Now, you can make unit tests with Selenium, in a fast way and run them into your machine or
remotely.
I hope this tutorial might be helpful.

Mais conteúdo relacionado

Mais de Dalton Valadares

Internet das Coisas com Edgex Foundry
Internet das Coisas com Edgex FoundryInternet das Coisas com Edgex Foundry
Internet das Coisas com Edgex FoundryDalton Valadares
 
OPTEE on QEMU - Build Tutorial
OPTEE on QEMU - Build TutorialOPTEE on QEMU - Build Tutorial
OPTEE on QEMU - Build TutorialDalton Valadares
 
Presentation of my paper in the IEEE Symposium on Computer and Communications...
Presentation of my paper in the IEEE Symposium on Computer and Communications...Presentation of my paper in the IEEE Symposium on Computer and Communications...
Presentation of my paper in the IEEE Symposium on Computer and Communications...Dalton Valadares
 
Avaliação de Desempenho de uma Rede 802.11g em uma Usina Termoelétrica
Avaliação de Desempenho de uma Rede 802.11g em uma Usina TermoelétricaAvaliação de Desempenho de uma Rede 802.11g em uma Usina Termoelétrica
Avaliação de Desempenho de uma Rede 802.11g em uma Usina TermoelétricaDalton Valadares
 
Apresentação sobre o modelo de segurança OPC UA
Apresentação sobre o modelo de segurança OPC UAApresentação sobre o modelo de segurança OPC UA
Apresentação sobre o modelo de segurança OPC UADalton Valadares
 
Modelo de segurança OPC UA
Modelo de segurança OPC UAModelo de segurança OPC UA
Modelo de segurança OPC UADalton Valadares
 
Introdução à Gestão de projetos
Introdução à Gestão de projetosIntrodução à Gestão de projetos
Introdução à Gestão de projetosDalton Valadares
 
Integrating Fiware Orion, Keyrock and Wilma
Integrating Fiware Orion, Keyrock and WilmaIntegrating Fiware Orion, Keyrock and Wilma
Integrating Fiware Orion, Keyrock and WilmaDalton Valadares
 
Desenvolvimento Web com JSF
Desenvolvimento Web com JSFDesenvolvimento Web com JSF
Desenvolvimento Web com JSFDalton Valadares
 
Comparison of signal smoothing techniques for use in embedded system for moni...
Comparison of signal smoothing techniques for use in embedded system for moni...Comparison of signal smoothing techniques for use in embedded system for moni...
Comparison of signal smoothing techniques for use in embedded system for moni...Dalton Valadares
 
Install and configure shiro plugin for authentication with Grails
Install and configure shiro plugin for authentication with GrailsInstall and configure shiro plugin for authentication with Grails
Install and configure shiro plugin for authentication with GrailsDalton Valadares
 
Xml to DB handler - grails tutorial
Xml to DB handler - grails tutorialXml to DB handler - grails tutorial
Xml to DB handler - grails tutorialDalton Valadares
 
Apresentação sobre artigo relacionado a Controle de Topologia em Redes de Sen...
Apresentação sobre artigo relacionado a Controle de Topologia em Redes de Sen...Apresentação sobre artigo relacionado a Controle de Topologia em Redes de Sen...
Apresentação sobre artigo relacionado a Controle de Topologia em Redes de Sen...Dalton Valadares
 
Apresentação sobre adaptação de topologia em redes móveis
Apresentação sobre adaptação de topologia em redes móveisApresentação sobre adaptação de topologia em redes móveis
Apresentação sobre adaptação de topologia em redes móveisDalton Valadares
 
How to configure an environment to cross-compile applications for beagleboard-xM
How to configure an environment to cross-compile applications for beagleboard-xMHow to configure an environment to cross-compile applications for beagleboard-xM
How to configure an environment to cross-compile applications for beagleboard-xMDalton Valadares
 
Texto sobre o livro "Uma verdade inconveniente"
Texto sobre o livro "Uma verdade inconveniente"Texto sobre o livro "Uma verdade inconveniente"
Texto sobre o livro "Uma verdade inconveniente"Dalton Valadares
 

Mais de Dalton Valadares (20)

Internet das Coisas com Edgex Foundry
Internet das Coisas com Edgex FoundryInternet das Coisas com Edgex Foundry
Internet das Coisas com Edgex Foundry
 
OPTEE on QEMU - Build Tutorial
OPTEE on QEMU - Build TutorialOPTEE on QEMU - Build Tutorial
OPTEE on QEMU - Build Tutorial
 
Presentation of my paper in the IEEE Symposium on Computer and Communications...
Presentation of my paper in the IEEE Symposium on Computer and Communications...Presentation of my paper in the IEEE Symposium on Computer and Communications...
Presentation of my paper in the IEEE Symposium on Computer and Communications...
 
Avaliação de Desempenho de uma Rede 802.11g em uma Usina Termoelétrica
Avaliação de Desempenho de uma Rede 802.11g em uma Usina TermoelétricaAvaliação de Desempenho de uma Rede 802.11g em uma Usina Termoelétrica
Avaliação de Desempenho de uma Rede 802.11g em uma Usina Termoelétrica
 
Apresentação sobre o modelo de segurança OPC UA
Apresentação sobre o modelo de segurança OPC UAApresentação sobre o modelo de segurança OPC UA
Apresentação sobre o modelo de segurança OPC UA
 
Modelo de segurança OPC UA
Modelo de segurança OPC UAModelo de segurança OPC UA
Modelo de segurança OPC UA
 
Introdução à Gestão de projetos
Introdução à Gestão de projetosIntrodução à Gestão de projetos
Introdução à Gestão de projetos
 
Integrating Fiware Orion, Keyrock and Wilma
Integrating Fiware Orion, Keyrock and WilmaIntegrating Fiware Orion, Keyrock and Wilma
Integrating Fiware Orion, Keyrock and Wilma
 
Programação C - Aula 1
Programação C - Aula 1Programação C - Aula 1
Programação C - Aula 1
 
Programação C - Aula 2
Programação C - Aula 2Programação C - Aula 2
Programação C - Aula 2
 
Programação C - Aula 3
Programação C - Aula 3Programação C - Aula 3
Programação C - Aula 3
 
Programação C - Aula 4
Programação C - Aula 4Programação C - Aula 4
Programação C - Aula 4
 
Desenvolvimento Web com JSF
Desenvolvimento Web com JSFDesenvolvimento Web com JSF
Desenvolvimento Web com JSF
 
Comparison of signal smoothing techniques for use in embedded system for moni...
Comparison of signal smoothing techniques for use in embedded system for moni...Comparison of signal smoothing techniques for use in embedded system for moni...
Comparison of signal smoothing techniques for use in embedded system for moni...
 
Install and configure shiro plugin for authentication with Grails
Install and configure shiro plugin for authentication with GrailsInstall and configure shiro plugin for authentication with Grails
Install and configure shiro plugin for authentication with Grails
 
Xml to DB handler - grails tutorial
Xml to DB handler - grails tutorialXml to DB handler - grails tutorial
Xml to DB handler - grails tutorial
 
Apresentação sobre artigo relacionado a Controle de Topologia em Redes de Sen...
Apresentação sobre artigo relacionado a Controle de Topologia em Redes de Sen...Apresentação sobre artigo relacionado a Controle de Topologia em Redes de Sen...
Apresentação sobre artigo relacionado a Controle de Topologia em Redes de Sen...
 
Apresentação sobre adaptação de topologia em redes móveis
Apresentação sobre adaptação de topologia em redes móveisApresentação sobre adaptação de topologia em redes móveis
Apresentação sobre adaptação de topologia em redes móveis
 
How to configure an environment to cross-compile applications for beagleboard-xM
How to configure an environment to cross-compile applications for beagleboard-xMHow to configure an environment to cross-compile applications for beagleboard-xM
How to configure an environment to cross-compile applications for beagleboard-xM
 
Texto sobre o livro "Uma verdade inconveniente"
Texto sobre o livro "Uma verdade inconveniente"Texto sobre o livro "Uma verdade inconveniente"
Texto sobre o livro "Uma verdade inconveniente"
 

Último

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Último (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

How to Configure Selenium WebDriver to Run in Eclipse, programming with Java

  • 1. Dalton Valadares – Universidade Federal de Campina Grande Embedded Systems and Pervasive Computing Lab (Embedded) How to configure Selenium WebDriver to run with Eclipse programming in Java -Download the latest version of Selenium WebDriver Java client driver: http://selenium- release.storage.googleapis.com/2.40/selenium-java-2.40.0.zip (Currently, I am using the 2.39.0 version, but the 2.40.0 is already available). If you will use another programming language, you must download the corresponding driver for it (C#, Python, Ruby); -Extract the content of the selenium-java-2.40.0.zip in a selected folder; -Open Eclipse in your project or create a new one; -Add the Selenium JARs to your project: *Right click on your project's name; *'Properties' --> 'Java Build Path'; *Click on 'Add External JARs' button; *Select the two JARs in your Selenium folder (selenium-java-2.39.0-srcs.jar and selenium- java-2.39.0.jar) and click open; *Click on 'Add External JARs' button again; *Open the libs folder which is inside the Selenium folder; *Select all the JARs inside libs folder and click open; -Now, the Eclipse is configured to run Selenium WebDriver tests. Using Chrome and Internet Explorer to run tests with Selenium -If you will not use the Firefox browser to run your tests, for each browser, it is necessary to have its respective driver; -Download the latest version of each in the following links: *Chrome driver - http://chromedriver.storage.googleapis.com/index.html?path=2.9/ *Internet Explorer driver - http://selenium- release.storage.googleapis.com/index.html?path=2.40/ -Put them in your PATH (the path to the executable files in your Environment Variables); -Test with some code like the below one: public class TestRMS{ public static void main(String[] args) throws InterruptedException {
  • 2. System.setProperty("webdriver.chrome.driver", "C:UsersdaltonDocumentsRMSchromedriver.exe"); System.setProperty("webdriver.ie.driver", "C:UsersdaltonDocumentsRMSIEDriverServer.exe"); WebDriver chromeDriver = new ChromeDriver(); executeTest(chromeDriver); chromedriver.close(); DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKIN ESS_BY_IGNORING_SECURITY_DOMAINS, true); WebDriver ieDriver = new InternetExplorerDriver(capabilities); executeTest(ieDriver); ieDriver.close(); } private static void executeTest(WebDriver driver) throws InterruptedException { driver.get("http://www.google.com"); driver.findElement(By.id("gbqfq")).clear(); driver.findElement(By.id("gbqfq")).sendKeys("Selenium Webdriver"); System.out.println(driver.getCurrentUrl() + " " + driver.getTitle()); driver.findElement(By.cssSelector("em")).click(); System.out.println(driver.getCurrentUrl() + " " + driver.getTitle()); } } -If you have problem executing the test with Internet Explorer driver, maybe you should try to change the Protected Zone in the browser (Protected Mode must be set to the same value, enabled or disabled, for all zones). Option found in the Advanced tab of the Internet Options dialog. Accelerating your tests creation -For make the process of test creation faster, install the Firefox Selenium Plugin (Selenium IDE): http://release.seleniumhq.org/selenium-ide/2.5.0/selenium-ide-2.5.0.xpi (let the Firefox install this plugin); -With the Selenium IDE installed on Firefox, open it, clicking in Tools --> Selenium IDE;
  • 3. -The Selenium IDE will open and you can record some commands with it, clicking in the red ball in right upper corner or clicking the right option in Menu Actions; -After you record some actions of your test, you must to import your script to run with other browsers. To do this, click on Menu File --> Export Test As... --> Java / JUnit4 / WebDriver (here you can choose any other type of file, with a different programming language, for example); -This way, you can edit your test in Eclipse, for example, and run your tests with other browsers. Running tests in a remote browser (remote machine) -To run tests in a remote browser, you have to download the Selenium Grid in the remote machine: http://selenium-release.storage.googleapis.com/2.40/selenium-server-standalone- 2.40.0.jar (this link is for 2.40.0 version) -In a command prompt/terminar, run the following command: java -jar ./selenium-server- standalone-2.40.0.jar -Dwebdriver.chrome.driver='/your/path/to/chromedriver.exe' (if you will use other browser, like IE, you must to change this parameter/path at the command); -In your code, to run the test(s) remotely, put code like the below: DesiredCapabilities capability = DesiredCapabilities.chrome(); //If you want to change the browser, change the capability here... capability.setPlatform(Platform.WINDOWS); //setPlatform(Platform.LINUX); capability.setVersion("10"); try { driver = new RemoteWebDriver(new URL("http://your.remote.IP.Address:4444/wd/hub"), capability); //put your remote IP here } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } -Run your tests. Now, you can make unit tests with Selenium, in a fast way and run them into your machine or remotely. I hope this tutorial might be helpful.