Trabla: NetBeans IDE with Selenium and Chrome Driver - installation and setup ( QA / Software Testing Automation )
NetBeans is an integrated development environment (IDE) for Java. NetBeans allows applications to be developed from a set of modular software components called modules. NetBeans runs on Microsoft Windows, macOS, Linux and Solaris. In addition to Java development, it has extensions for other languages like PHP, C, C++ and HTML5., Javadoc and Javascript. Applications based on NetBeans, including the NetBeans IDE, can be extended by third party developers
Selenium is a portable software-testing framework for web applications. Selenium provides a playback (formerly also recording) tool for authoring tests without the need to learn a test scripting language (Selenium IDE). It also provides a test domain-specific language (Selenese) to write tests in a number of popular programming languages, including C#, Groovy, Java, Perl, PHP, Python, Ruby and Scala. The tests can then run against most modern web browsers. Selenium deploys on Windows, Linux, and macOS platforms. It is open-source software, released under the Apache 2.0 license
Solving:
1. Download and install latest Java Development Kit ( JDK )
- goto Oracle Java Development Kit ( JDK ) official site :
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
- download and install latest Java Development Kit ( JDK )
2. Download and install NetBeans IDE from official site
- goto NetBeans IDE official site in browser : https://netbeans.org/downloads/- select NetBean version, we will use Java SE version, and click Download button
- install NetBeans IDE to your computer
3. Download Selenium standalone server from official site
- goto official Selenium site : https://www.seleniumhq.org/download/- find paragraph "Selenium Standalone Server"
- find Download version 3.10.0 and click on link
4. Download Chromer Driver ( browser automation ) for Selenium
- goto official Selenium site : https://www.seleniumhq.org/download/- find header "Third Party Browser Drivers NOT DEVELOPED by seleniumhq"
and click on "Google Chrome Driver"
- in newly opened web-site of Chrome WebDriver site
click on ChromeDriver 2.35 link
click on ChromeDriver 2.35 link
- click on "chromedriver_win32.zip" link to start download Chrome Driver for Windows
- unzip chromerdriver_win32.zip
- create folder C:\selenium_browser_drivers and copy chromedriver.exe to folder
5. Run NetBeans IDE
6. Create new Java project in NetBeans IDE
- in NetBeans menu click "File", than click "New Project..."- in NetBeans "New Project..." dialog
1) select category "Java"
2) select "Java Application"
3) click "Next >" button
- in NetBeans "New Java Application" dialog
1) type project name "SeleniumChrome"
2) click "Finish" button
7. Import selenium-standalone jar into Netbeans IDE project
- right mouse click on "SeleniumChrome" in Project Tree- in menu select "Properties"
- in NetBeans "Project Properties" dialog :
1) select Category "Libraries"
2) click "Add JAR/Folder" button
- in NetBeans "Add JAR/Folder" dialog :
1) find and select selenium-server-standalone-3.10.0.jar
2) click "Open" button
- in NetBeans "Project Properties" dialog - click "Ok" button
8. Copy and paste following Java code for Selenium simple test into Netbeans IDE
/** To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package seleniumchrome;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
/**
*
* @author your_name :)
*/
public class SeleniumChrome {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.setProperty(
"webdriver.chrome.driver",
"/selenium_browser_drivers/chromedriver.exe"
// C:\selenium_browser_drivers\chromedriver.exe
);
// Create a new instance of the Chrome driver
WebDriver driver = new ChromeDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
// Alternatively the same thing can be done like this
// driver.navigate().to("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
// Enter something to search for
element.sendKeys("Cheese!");
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
});
// Should see: "cheese! - Google Search"
System.out.println("Page title is: " + driver.getTitle());
//Close the browser
driver.quit();
}
} // code end :)
9. Run Selenium project in NetBeans IDE
Hooray !!! Enjoy NetBeans IDE with Selenium and Chrome Driver
No comments:
Post a Comment