Sethupathi
Sethupathi

Reputation: 11

How to retrieve SUT System Time in Eggplant

We have tried using IST minus the difference between IST and CST, so that we can get CST time (the SUT's time), but it won't work when daylight saving time comes. Kindly someone help on this to get the SUT time.

Upvotes: 0

Views: 1036

Answers (1)

GetHacked
GetHacked

Reputation: 564

You can't directly take the time zone from a SUT. There are a few methods to do what you're trying to accomplish:

1. Screen capture the time on the SUT.

Using OCR, isolate the searchRectangle to the system's clock. Then readtext() and save the read text to a variable myTime.


2. Remote commands (mobile SUTs only).

You can send a remote command to a SUT using the Eggplant function ExecuteRemoteCommand(). From Eggplant's documentation:

  • "On Android, ExecuteRemoteCommand runs as a shell command on the actual phone.

  • On iOS, ExecuteRemoteCommand runs the command as JavaScript, making calls to the Apple UIAutomation API."

You can save the output of these commands to a variable, so on an Android SUT it would be:

set SUT_time to ExecuteRemoteCommand(date)

SUT_time will now represent the time in the format Mon Jul 31 21:09:28 CDT 2017.


3. Math!

Given your current system's date and time, you should always be able to calculate the time of any given timezone. Currently, that would work out as:

set SUT_time to the date minus 10 hours 30 minutes

To make this compatible with daylight saving's time, you'll have to use an if statement. That might look something like this:

set CST to the date minus 10 hours 30 minutes
if CST is between "Mar 11" and "Nov 4" then
    add 1 hour to CST
end if

Upvotes: 0

Related Questions