Share
Go down
ramaswamy
Active particpant
Active particpant
Posts : 22
Join date : 2011-11-28

urgent- please give me one example of data driven data program in selenium rc using java language

on Tue Nov 29, 2011 10:05 am
Hi All

please give one example data driven data program in java language.
susmitha
Active particpant
Active particpant
Posts : 15
Join date : 2011-10-21

Re: urgent- please give me one example of data driven data program in selenium rc using java language

on Tue Nov 29, 2011 12:36 pm
import java.io.FileInputStream;
import java.io.FileOutputStream;

import jxl.Sheet;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

import com.thoughtworks.selenium.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.*;

public class DataDrivenTestingUsingJunit {
private Selenium selenium;
private SeleniumServer seleniumserver;

@Before
public void setUp() throws Exception {
RemoteControlConfiguration rc = new RemoteControlConfiguration();
seleniumserver = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://");
seleniumserver.start();
selenium.start();
selenium.setSpeed("3000");
}

@Test
public void testImportexport1() throws Exception {

// Read data from excel sheet
FileInputStream fis = new FileInputStream(
"src/resources/GmailTestData.xls");
Workbook w = Workbook.getWorkbook(fis);
Sheet s = w.getSheet(0);
String a[][] = new String[s.getRows()][s.getColumns()];
// Write the input data into another excel file
FileOutputStream fos = new FileOutputStream(
"src/resources/GmailTestResult.xls"); //create a folder resources in ecllipse src folder and initialize the GmailTestResult.xls which data you want to test test.xls file
// Be sure that the extension of file should be .xls not .xlsx

WritableWorkbook writableBook = Workbook.createWorkbook(fos);
WritableSheet destinationSheet = writableBook.createSheet("loginresult1", 0);

selenium.open("http://www.gmail.com");
selenium.windowMaximize();

System.out.println("s.getRows() = " + s.getRows());

for (int i = 0; i < s.getRows(); i++) {
System.out.println("s.getColumns = " + s.getColumns());
for (int j = 0; j < s.getColumns(); j++) {
a[i][j] = s.getCell(j, i).getContents();
Label l = new Label(j, i, a[i][j]);
Label l1 = new Label(2, 0, "Result");
destinationSheet.addCell(l);
destinationSheet.addCell(l1);
}
}

for (int i = 1; i < s.getRows(); i++)
{
selenium.type("Email", s.getCell(0, i).getContents());
selenium.type("Passwd", s.getCell(1, i).getContents());
selenium.click("signIn");
selenium.waitForPageToLoad("30000");

boolean aa = selenium
.isTextPresent("The username or password you entered is incorrect. ?");
System.out.println("the value of aa is::" + aa);
if (aa)
{

Label l3 = new Label(2, i, "fail");

destinationSheet.addCell(l3);
System.out.println("Login Failure");
Thread.sleep(10000);

}
else
{
Label l2 = new Label(2, i, "pass");
destinationSheet.addCell(l2);
String str = selenium.isElementPresent("link=Sent Mail") == true ? "true"
: "false";
selenium.waitForCondition(selenium
.isElementPresent("link=Sent Mail") == true ? "true"
: "false", "60000");
selenium.click("link=Sent Mail");
selenium.click("gbgs4");
selenium.click("gb_71");
http://selenium.waitForPageToLoad("30000");
Thread.sleep(10000);
}
}
writableBook.write();
writableBook.close();
}

@After
public void tearDown() throws Exception {
selenium.stop();
seleniumserver.stop();

}
}
ramaswamy
Active particpant
Active particpant
Posts : 22
Join date : 2011-11-28

Re: urgent- please give me one example of data driven data program in selenium rc using java language

on Tue Nov 29, 2011 5:25 pm
thank you so much susmitha
sachin123
Posts : 7
Join date : 2011-11-29

Re: urgent- please give me one example of data driven data program in selenium rc using java language

on Sat Dec 03, 2011 2:27 am
above program is not executed susmitha.

only firefox broser opened and terminated the program what i do now?
lalkota
Active particpant
Active particpant
Posts : 21
Join date : 2011-06-02

Re: urgent- please give me one example of data driven data program in selenium rc using java language

on Tue Dec 06, 2011 5:29 pm
Message reputation : 0% (1 vote)
ramaswamy
Active particpant
Active particpant
Posts : 22
Join date : 2011-11-28

Re: urgent- please give me one example of data driven data program in selenium rc using java language

on Tue Dec 13, 2011 4:40 pm
am using using Selenium RC with JUnit and testng jar files are

junit-4.8.2.jar
jxl.jar
selenium-grid-tools-1.0.8.jar
selenium-java-client-driver.jar
selenium-server.jar
testng-5.14.jar


but, which jar files are using in webdriver please give me solution...........
Sponsored content

Re: urgent- please give me one example of data driven data program in selenium rc using java language

Back to top
Permissions in this forum:
You cannot reply to topics in this forum