이 코드는 xls
파일을 읽고이를 테스트 측에 삽입합니다. 또한 xls
파일의 값이 존재하는지 여부를 데이터베이스에서 확인하고 페이지 제목과 비교합니다.com.microsoft.sqlserver.jdbc.SQLServerException : nvarchar 값 '123.0'을 데이터 형식 int로 변환 할 때 변환하지 못했습니다.
테스트가 실패하고 다음과 같은 오류를
com.microsoft.sqlserver.jdbc.SQLServerException을주고있다 : int 데이터 형식으로 NVARCHAR 값 '123.0'을 변환 할 때 변환에 실패했습니다.
내 데이터베이스에서 forceID는 INT 타입이며,이 코드에 문자열입니다하지만 난
int q= (int)Double.parseDouble(forceID);
도와주세요 다음 줄에 변환! SQL Server 2008을 사용하고 R2, 셀레늄 WebDriver 및 Java
public void loginTest(String forceID,String user,String password)
throws InterruptedException, IOException, SQLException{
// test runmode of current dataset
count++;
if(!runmodes[count].equalsIgnoreCase("Y")) {
skip = true;
throw new SkipException ("Runmode for test set data is set to no"+ count);
}
APP_LOGS.debug("Excuting Login Test");
APP_LOGS.debug(forceID +" -- "+ user +" -- "+ password +" -- ");
openBrowser();
driver.get(CONFIG.getProperty("testSiteName"));
connToDatabase();
// Check the db
try{
pstmt=conn.prepareCall("select * from Login where ForceID=? and Username=? and Password=?");
pstmt.setString(1,forceID);
pstmt.setString(2,user);
pstmt.setString(3,password);
rs=pstmt.executeQuery();
valueFound =rs.next();
}catch(Exception e){
e.printStackTrace();
}
//log in to the app
getObject("forceID").clear();
int q= (int)Double.parseDouble(forceID);
getObject("forceID").sendKeys(String.valueOf(q));
//getObject("forceID").sendKeys(forceID);
getObject("user").clear();
getObject("user").sendKeys(user);
getObject("password").clear();
getObject("password").sendKeys(password);
getObject("logOn").click();
// get the title
String actual_title=driver.getTitle();
System.out.println(actual_title);
System.out.println(valueFound);
if (valueFound) {
Assert.assertEquals(actual_title, "Dashboard");
} else {
Assert.assertEquals(actual_title, "Logon");
}
}
int가 들어있는 필드에 문자열을 삽입하면 문제가되지 않습니까? 이것은 :'pstmt.setString (1, forceID);'는 아마도 setInt (1, Integer.parseInt (ForceID)) 또는 이와 비슷한 것을 사용해야합니다. – jpw
예외가 던져지는 곳은 어디인가? 나는 그것이 rs = pstmt.executeQuery()에 있다고 가정했다; 이제는 당신이 구체적이지 않다는 것을 깨닫습니다. –
감사합니다 jpw 및 David Waters –