Ask a Question

Concat Now Time in YYYYMMDDHH with LastName keyword test field as one string value

todd2
Contributor

Concat Now Time in YYYYMMDDHH with LastName keyword test field as one string value

I have this piece of code

# Obtain the current time
 TimeValue=aqDateTime.Time() # Obtain the current date and time
 NowValue=aqDateTime.Now() # Convert the returned date/time values to string values
 StringTimeValue = aqConvert.DateTimeToStr(TimeValue)
 StringNowValue = aqConvert.DateTimeToStr(NowValue) # Post the converted values to the log
 Log.Message(“The time obtained from the Time routine is ” + StringTimeValue)
 Log.Message(“The time obtained from the Now routine is ” + StringNowValue) # Convert the floating-point values to string values
 VariantTimeValue = aqConvert.FloatToStr(TimeValue)
 VariantNowValue = aqConvert.FloatToStr(NowValue) # Post the converted values to the log
 Log.Message(“The variant representation of TimeValue is “+ VariantTimeValue)
 Log.Message(“The variant representation of NowValue is “+ VariantNowValue)

 

I want to concat the The time obtained from the Now routine as YYYYMMDD and 24 hr format which the above does not look like.  I dont need the PM.  The name of the field to concat the time and date now function to is Aliases.browser.pageApplyNow6.formWouldYouLikeToIncludeA.textboxLastName

 

How can I achieve that in a unit script and when test executes the unit script fills out the LastName field with the entire string?  I want to store that result also in a temporary variable that will be called again later in the test and reset when the start of the test begins the next time.

 

Thank You,

 

Todd

21 REPLIES 21

Marsha,

 

This is what my log says after I run the unit3 script to show you that it is indeed echoing to the log output what I want

todd2_0-1683148109815.png

 

But when the keyword test script executes it only types America there not the result of the unit3 script output.

 

Sincerely,

 

todd2

Marsha,

 

See I want the contents of Unit3 to appear right at the text control in the picture provided. 

 

todd2_0-1683148482314.png

 

Thank You,

 

todd2

Marsha_R
Champion Level 2

I get it!  🙂

 

Even though your unit3 script output looks good, I am concerned that the variable value is not what we expect it to be.

 

Please output UpdatedLastName to the log in the keyword test (not in the script) at the point right before you try to put it in the text box and let's see what the variable has in it at that moment.

Marsha,

 

Yes, I bet the variable is reporting the default value of America (because I thought you cant leave that blank you have to initialize the variable with something) not changing to what is in the contents of Unit3 script.  How do I, when creating a Project Variable, tell it to go get the contents of Unit3? 

 

Thank You,

 

todd2

Marsha_R
Champion Level 2

Let's test that.  Make the default in the variable be something like "abcdefg" instead of "America", so we can really tell the difference when the updated string is added. 

Confirmed.  abcdefg is what is written in the text box not what is coming from unit3 script output?  I want unit3 output to land into the lastname textbox object.

Marsha_R
Champion Level 2

Make sure that UpdatedLastName is a Project or ProjectSuite level variable so that it is available at all times in your test.

See if that helps and let me know!

Marsha,

 

It is.

 

todd2_0-1683200920388.png

todd2

Marsha,

 

So we can get Unit3 to output to the log America and the Date and Time in the format we seek.  What we cant get accomplished is the Project variable is not receiving that value even though I told it to do so in the Unit script.  I even initialized the variable by placing a default value in it and it will not change to what I want at keyword test script execution time.  How come?

 

todd2

Marsha_R
Champion Level 2

I see that you have it as a Temporary Variable but I want to make sure that it is at the Project level and not just for the Keyword Test.  Here's an example:

 

Marsha_R_0-1683222087018.png

 

cancel
Showing results for 
Search instead for 
Did you mean: