Please find Selenium example Walkthru. (Win 7- 64 bit)
1. Installed Java and Eclipse followed the below links http://geekswithblogs.net/Saqib/archive/2008/01/03/setting-up-selenium-rc-server-in-windows.aspx
2. Download Testng from http://testng.org/doc/download.html
4. Second very good walkthrough is available in http://epyramid.wordpress.com/2008/11/26/setting-up-selenium-rc-testng-using-eclipse/. This link does not seem to exist now, You need to download Eclipse IDE for Java Developers. (Check Links - Link1)
5. Run Eclipse program as Administrator
6. Got Error ‘Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path! Please add the directory containing firefox.exe to your PATH environment’
7. Fix is below line of code
selenium = new DefaultSelenium("localhost", 4444, "*firefox C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe",http://yahoo.com/);
9. Code Example
import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;
public class GoogleTest
{public Selenium selenium;
public void setup()
{
selenium = new DefaultSelenium("localhost", 4444, "*firefox C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe","http://google.com");
selenium.start();}
public void search()
{
selenium.open("http://www.Google.com/");selenium.type("q", "selenium rc");
selenium.click("btnG");
selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("seleniumhq.org"));
}
public static void main(String arg[]){
GoogleTest g = new GoogleTest();
g.setup();
g.search();
}
}
10. Export it as Ant Files. Select Export Option by right click on the Project node. Choose ANT build files from below window
11. Choose the Project to create ANT build file
Reference Link. Build file created with all the contents of the project.
TestNG makes Java unit testing a breeze
Cedric Beust - Test NG
Data Driven Testing using Selenium & TestNG Part 1 of 4
Selenium Remote Control and TestNG
More Reads
Login Scenario - Providing Login Detail from Excel Sheet
Data Driven Testing Using Selenium RC with TestNG
WebDriver with Excelsheet
Happy Reading!!
No comments:
Post a Comment