1
以下代碼是Selenium Webdriver中的Java代碼。代碼從excel表格中讀取一個長列表。它將每個Excel單元格中的值存儲在變量LastName
和FirstName
中。在導航到SQL Server管理工作室數據庫之後,我需要在查詢中使用這些變量。這是我遇到問題的地方。當我使用命令'screen.type(LastName);'時,變量LastName
拋出「無法解析爲變量」錯誤。在Selenium-Webdriver中使用Sikuli的Java變量
如何使用Sikuli中Java中定義的變量LastName
和FirstName
。
File src = new File ("C:\\EmployeeList.xlsx");
FileInputStream fis = new FileInputStream(src);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet1 = wb.getSheetAt(0);
int rowcount=sheet1.getLastRowNum();
System.out.println("Total Row is :" + rowcount);
for (int i=0; i<rowcount;i++) {
String LastName=sheet1.getRow(i).getCell(0).getStringCellValue();
String FirstName=sheet1.getRow(i).getCell(1).getStringCellValue();
System.out.println("Data Employee List is " +i+ " "+"is "+ LastName+ ", "+FirstName+");
}
wb.close();
//Navigated into SQL Server management studio database
screen.type(LastName);
謝謝!感謝幫助。其目的是從Excel表格中每行的每個單元格中獲取值。使用SQL查詢中的值,然後返回Excel表格中的下一行。 – sama