SlideShare une entreprise Scribd logo
1  sur  3
Télécharger pour lire hors ligne
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.

Contenu connexe

Plus 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
 

Plus 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"
 

Dernier

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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 Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Dernier (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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 Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

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.