在我的网站中,我可以选择一个日期范围并列出该日期范围内的所有内容。我的测试用例是验证列出的交易日期是否在所选日期范围内。
这是我的代码。我将所有交易日期保存到UI表中。
但是当我跑步时,我得到了You cannot call a method on a null-valued expression.
At line:88 char:9
+ $members = $this.super.retrieve.members() # !!! Problem exist ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
你能帮忙吗?这段代码有什么问题?
Unparseable date: "07/16/19"
customFormatter:
public boolean verifyTableDate(WebElement ElementTable, int columnNumber, String fromDate, String toDate){
boolean result = true;
String columnValue = "";
WebElement disputeTableElem = null;
List<WebElement> cellsTR;
List<WebElement> cellsTD;
int ctr;
SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yy");
SimpleDateFormat fmt1 = new SimpleDateFormat("MMM/dd/yyyy");
Date parseFromDate;
Date parseToDate;
Date dateColumnVal;
disputeTableElem = ElementTable;
cellsTR = disputeTableElem.findElements(By.tagName("tr"));
cellsTD = null;
print("DATE RANGE: "+ fromDate + " - " + toDate);
waitUntilPageLoadingIsComplete();
for (WebElement cellTR : cellsTR) {
cellsTD = cellTR.findElements(By.tagName("td"));
ctr = 0;
for (WebElement cellTD : cellsTD) {
ctr++;
if (ctr == columnNumber) {
columnValue = cellTD.getText().trim().replaceAll("\n", " ");
columnValue = columnValue.substring(0,8);
try {
dateColumnVal = fmt.parse(columnValue);
parseFromDate = fmt1.parse(fromDate);
parseToDate = fmt1.parse(toDate);
String dateColumnValString = fmt.format(dateColumnVal);
if (dateColumnVal.compareTo(parseFromDate) >= 0 && dateColumnVal.compareTo(parseToDate) <= 0) {
print(dateColumnValString + " is within date range.");
highLightElement(cellTD);
result = true;
}else {
errorDesc += dateColumnValString + " is not within date range.";
result = false;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
}
return result;
}
customFormatter1
DateTimeFormatter customFormatter = DateTimeFormatter.ofPattern("MMM/dd/YYYY");
String endDate = LocalDate.now(ZoneId.of(zoneID_EST)).format(customFormatter);
String startDate = LocalDate.now(ZoneId.of(zoneID_EST)).minusDays(100).format(customFormatter);