I working on getting results from a search for the “Last 30 Days”
How can I verify that the results are correct? ex. I select 10/21/2019 and choose “Last 30 Days” and my result is “09/23/2019” in Ascending order!
I working on getting results from a search for the “Last 30 Days”
How can I verify that the results are correct? ex. I select 10/21/2019 and choose “Last 30 Days” and my result is “09/23/2019” in Ascending order!
You can accomplish this using Java’s SimpleDateFormat class and Date class:
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy")
Date inputDate = sdf.parse("10/21/2019")
// code to select 10/21/2019...
List<WebElement> resultDateElements = WebUiCommonHelper.findWebElements(findTestObject("path/to/my/object"), 30)
for(WebElement dateElement : resultDateElements) {
Date resultDate = sdf.parse(dateElement.getText());
assert inputDate.after(resultDate) || inputDate.equals(resultDate)
}
Thanks @Brandon_Hein
Im trying to stay away from hard coding here is code Im working on
I need to get todays (will change) verify its there
than verify the ascending date (Lat 30 Days) and verify its there
Not sure what you mean, you are “hard-coding” this in your example…
Are you having more trouble locating the elements, or with the actual validation part?
Trying to not use a “10/21/2019”
Maybe having trouble with both new to automation
I think we’re actually having trouble agreeing on/communicating your requirements. Ok so you want to generate today’s date. No problem. Again, using the SimpleDateFormat and Date libs:
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy")
String todaysDate = sdf.format(new Date())
This will generate a new date each time, set to today’s date in month/day/year format.
awesome thank you
how do I verify it is todays date in a search?