Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

s lekkala

Greenhorn
+ Follow
since Jul 25, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by s lekkala

Recently i have worked on that, so find the below code to understand the solution..

The below code used to read the data from excel sheet and returns the array.

@DataProvider(name = "PegaDataPool")
public Object[][] createDataPool(Method testMethods) {
ExcelReader readExcel = new ExcelReader();
List<String> tableName = new LinkedList();
if (testMethods.getName().equalsIgnoreCase("testNewCaseRegistration")) {
tableName.add("pegaUserData");
Object[][] retObjArr = readExcel.getTableArray("C:/workspace/VTAF-4.0/src/TestData/PegaTestData.xls","Pega User", tableName);
return (retObjArr);
}
return null;
}

you can use above values in the below methods

@Test(dataProvider = "PegaDataPool")
public void testNewCaseRegistration(String branch, String enquiryAmount,String debitAmount, String transactionDate, String tableName)throws Exception {

these branch, enquiryAmount variables can use whenever you require the data present in it.

}

Please find the attachment to know the data present in excel sheet.


Hope it will be useful to u...


10 years ago
Hi,
While click on button i am getting the response in new window. Can i handle that new window by using selenium or webdriver? Even i dont the the ID/CSS/Xpath of the new window.

Please help me to move forward.

Thanks,
Sreenu...
10 years ago
Hi,

I have recorded one scenario by using slenium IDE, it is working fine while executing the same scenario by using selenium IDE. But while executing the testcases as Junit4(webdriver) and Junit4(Backed selenium) its getting failed to get the frames. Can anyone suggest to solve the problem.

TC which is exported as BackedSelenium:

@Test
public void testManagerSelenium() throws Exception {
selenium.open("http://10.4.177.248:9866/prweb/PRServlet");
selenium.type("id=txtUserID", "manager@virtusa.com");
selenium.type("id=txtPassword", "rules");
selenium.click("name=pyActivity=Code-Security.Login");
selenium.waitForPageToLoad("30000");
selenium.click("css=#Tab2 > #ACCORANCHOR > #TABSPAN > #RULE_KEY > tbody > tr > td.accord_titleBarBackground");
selenium.selectFrame("PWGadget0Ifr");
selenium.click("//table[@id='ViewTable']/tbody/tr[7]/td[3]");
selenium.waitForPageToLoad("10000");
//--Unable to find this below frames
selenium.selectFrame("relative=up");
selenium.selectFrame("PWGadget1Ifr");


selenium.select("id=ManagerApprovalLatest", "label=Approve");
selenium.type("id=ManagerComments", "enter value for the reason");
selenium.click("id=submitButton");
selenium.waitForPageToLoad("30000");
}


TC which is exportedAs Junit4(Webdirver):

@Test
public void testManagerDriver() throws Exception {
driver.get(baseUrl + "/prweb/PRServlet/oO9O9iMscyJc_fy6LnBDXO9xEtRpDxfL3At36r8Aw8k%5B*/!STANDARD?");
driver.findElement(By.id("txtUserID")).clear();
driver.findElement(By.id("txtUserID")).sendKeys("manager");
driver.findElement(By.id("txtPassword")).clear();
driver.findElement(By.id("txtPassword")).sendKeys("rules");
driver.findElement(By.name("pyActivity=Code-Security.Login")).click();
driver.findElement(By.cssSelector("#Tab2 > #ACCORANCHOR > #TABSPAN > #RULE_KEY > tbody > tr > td.accord_titleBarBackground")).click();
//----Unable to find the below Frame
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame]]
driver.findElement(By.xpath("//table[@id='ViewTable']/tbody/tr[9]/td[3]")).click();
//----Unable to find the below Frames
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame]]
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame]]

new Select(driver.findElement(By.id("ManagerApprovalLatest"))).selectByVisibleText("Approve");
driver.findElement(By.id("ManagerComments")).clear();
driver.findElement(By.id("ManagerComments")).sendKeys("enter value for the reason");
driver.findElement(By.id("submitButton")).click();
}



Thanks & Regards,
Lekkal
10 years ago
Ya Clampham, its valid file but i am unable to read it.
10 years ago
Thanks for your reply Stephen, but i got to know the problem by using jxl.jar so i have switched to POI. Here i am getting the below Exception so can you please solve my problem if it is known:
java.io.IOException: Unable to read entire header; 0 bytes read; expected 512 bytes
at org.apache.poi.poifs.storage.HeaderBlockReader.alertShortRead(HeaderBlockReader.java:149)
at org.apache.poi.poifs.storage.HeaderBlockReader.<init>(HeaderBlockReader.java:85)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:151)
at POIExcelReader.displayFromExcel(POIExcelReader.java:48)
at POIExcelReader.main(POIExcelReader.java:72)

I have used below code:

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

/**
*
* @author Sreenu
*/
public class POIExcelReader {

/** Creates a new instance of POIExcelReader */
public POIExcelReader() {
}

/**
* This method is used to display the Excel content to command line.
*
* @param xlsPath
*/
public void displayFromExcel(String xlsPath) {
InputStream inputStream = null;

try {
inputStream = new FileInputStream(xlsPath);
} catch (FileNotFoundException e) {
System.out.println("File not found in the specified path.");
e.printStackTrace();
}

POIFSFileSystem fileSystem = null;

try {
fileSystem = new POIFSFileSystem(inputStream);

HSSFWorkbook workBook = new HSSFWorkbook(fileSystem);
HSSFSheet sheet = workBook.getSheetAt(0);
HSSFRow newrow = sheet.createRow(5);
System.out.println("Row created");
HSSFCell cell = newrow.createCell(5);
System.out.println("Cell created");
cell.setCellValue("Hi this is the first trail in POI");
System.out.println("Writes data into excel");
} catch (IOException e) {
e.printStackTrace();
}
}

/**
* The main executable method to test displayFromExcel method.
*
* @param args
*/
public static void main(String[] args) {
POIExcelReader poiExample = new POIExcelReader();
String xlsPath = "C:/Eclipse_workspace/Project/Result.xls";

poiExample.displayFromExcel(xlsPath);
}
}


10 years ago
Actually i am using this code for selenium, here i have to save the result of each selences code line. So every time i have to read the existed excel sheet and have to modify the sheet. Every day we have to create the new file and have to maintain the same file for daily status.
10 years ago
Hi,

can we refresh the directory in middle of executing the java code?
If excel sheet is not exists the below code creates and need to read same doc and modifies the data. My problem is i am unable to read the doc immediatly which was created at the instant(means fresh doc). So is there any alternate to read the existing doc.




Thanks,
Sreenu.

[Edit - added code tags, fixed formatting - MB]
10 years ago
Hi,
Here question is related to selenium RC on mac OS but here you people discussing about "ActyMac DutyWatch Remote". Can any one tell me the use of it..

Thanks,
seenuu...
10 years ago
Hi Tony,

Selenium can handle javascript overlay window as
selenium.selectFrame(elements.get("RELATIVEUP"));
selenium.selectFrame(elements.get("REQUESTWARNING_IFRAME"));
OR
selenium.selectWindow(elements.get("REQUESTWARNING_IFRAME"));

Regards,
seenu...
10 years ago
Hi Andre,
I have some work experience on selenium. So i can..

Regards,
seenu...
10 years ago
Hi,
I am new to selenium. I have doubts in the code can anyone clarify it...

why we should use setUp() and tearDown() methods...???

and its not working is there any mistake in the code??


package com.sreenu;

import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.DefaultSelenium;
import junit.framework.TestCase;
import org.openqa.selenium.server.SeleniumServer;

public class ExampleTest
extends TestCase
{
private static final String MAX_WAIT_TIME_IN_MS = "60000";
private static final String BASE_URL = "http://www.google.com";
private Selenium selenium = new DefaultSelenium( "localhost",
4444,
"*firefox",
BASE_URL);
private SeleniumServer seleniumServer;
public void setUp()
throws Exception
{
seleniumServer = new SeleniumServer();
seleniumServer.start();
selenium.start();
}

public void tearDown()
throws Exception
{
selenium.stop();
seleniumServer.stop();
}

public void testClickingLink()
throws Exception
{
selenium.open(BASE_URL);
Thread.sleep(20000);
selenium.click("css=a.gbzt.gbzt-hvr > span.gbts");
Thread.sleep(30000);
selenium.type("Email", "gmail address");
selenium.type("Passwd", "password");
selenium.click("signIn");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);

//String expectedTitle = "Bit Motif ยป Test Page For Selenium Remote Control";
//assertEquals(expectedTitle, selenium.getTitle());
}
}

Regards,
Seenuuuuuu..
10 years ago
Hi,

Thanks for you relpy ivan....
10 years ago
Hi William,
I am new to webservices so can you give me the detailed example.

Thanks,
sreenu
10 years ago
Hi,
I am also completely new to webservices...i have followed the procedures given in some sites to create a simple example but i am not able to write the client side program to access the corresponding wsdl file. so can anyone help me to access the wsdl.
Thanks,
seenu
10 years ago