Skip to content

Commit

Permalink
Fixing problems with the date (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocristian committed Jan 1, 2025
1 parent 0a2b8ca commit e53719a
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,15 @@ private void introduceSessionDate(BrowserUser user, WebElement element, String d
for (int i = 0; i < attempts; i++) {
try {
user.getDriver().findElement(SESSION_LIST_NEW_SESSION_MODAL_DATE).clear();
String[] splitDate = date.split("-");
user.getDriver().findElement(SESSION_LIST_NEW_SESSION_MODAL_DATE).sendKeys(date);
String invertedDate = splitDate[2] + "-" + splitDate[1] + "-" + splitDate[0];
String actualValue= user.getDriver().findElement(SESSION_LIST_NEW_SESSION_MODAL_DATE).getAttribute("value");
if(!actualValue.equals(invertedDate)) { // Use JavaScript to set the value of the date input
if(!actualValue.equals(date)) { // Use JavaScript to set the value of the date input
log.info("Selenium sendKeys dont working properly, using JS..");
user.getDriver().findElement(SESSION_LIST_NEW_SESSION_MODAL_DATE).clear();
JavascriptExecutor js = (JavascriptExecutor) user.getDriver();
js.executeScript("arguments[0].value = arguments[1];", user.getDriver().findElement(SESSION_LIST_NEW_SESSION_MODAL_DATE), invertedDate);
js.executeScript("arguments[0].value = arguments[1];", user.getDriver().findElement(SESSION_LIST_NEW_SESSION_MODAL_DATE), date);
}
user.getWaiter().until(ExpectedConditions.textToBePresentInElementValue(element.findElement(SESSION_LIST_NEW_SESSION_MODAL_DATE), invertedDate));
user.getWaiter().until(ExpectedConditions.textToBePresentInElementValue(element.findElement(SESSION_LIST_NEW_SESSION_MODAL_DATE), date));
success = true;
break; //
} catch (TimeoutException e) {
Expand All @@ -163,15 +161,15 @@ private void introduceSessionDate(BrowserUser user, WebElement element, String d
}
}
/**
* This method gets the current date in the format DDMMYYYY. for the video session name
* This method gets the current date in the format MMDDYYYY. for the video session name
*/
private String getCurrentDate() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
int mYear = calendar.get(Calendar.YEAR);
int mMonth = calendar.get(Calendar.MONTH);
int mDay = calendar.get(Calendar.DAY_OF_MONTH);
return "" + (mDay < 10 ? "0" + mDay : mDay)+"-" + (mMonth < 10 ? "0" + mMonth : mMonth)+"-"+ mYear;
return "" +(mMonth < 10 ? "0" + mMonth : mMonth) +"/" +(mDay < 10 ? "0" + mDay : mDay) +"/"+ mYear;
}
/**
* This method gets the current time in the format HHmmA/P, where A/P indicates AM or PM for the video session name
Expand Down

0 comments on commit e53719a

Please sign in to comment.