Excel 文件中提到的21.650
值与页面上显示的值相同。但是当脚本执行时,它会读取 Excel 值,21.65
并且我的断言条件变为 false。
List<string> rowValue = new List<string> { };
var ExcelFilePath = "D:\\testexcel.xlsx";
Excel.Application xlApp = new Excel.Application(ExcelFilePath);
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(ExcelFilePath);
Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
int rowCount = xlRange.Rows.Count;
for (int i = 1; i <= rowCount; i++)
{
rowValue.Add(xlRange.Cells[i, j].Value2.ToString());
IWebElement element = driver.FindElement(By.Id(weight_field));
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", element);
string weight = driver.FindElement(By.Id(weight_field)).Text;
if (mpuid == i)
{
Assert.AreEqual(weight,rowValue[0]);
Console.WriteLine(" Expected Value: " + rowValue[0] + " is equal to Actual Value: " + weight);
break;
}
rowValue.Clear();
}