Ask a Question

Copying variable

gdave
Regular Contributor

Copying variable

Hi all

 

This is what my test is suppose to do:

Copy the object property value in the project level variable

gdave_0-1621592579428.png

Then use the property checkpoint to validate the above variable. However, my checkpoint failed as the variable stored at the project level is with closing brackets. Even though I have used the 'Contains' condition, it still doesn't ignore the  "()" sign.

gdave_1-1621592896701.png

I wonder if there is a way I can get rid of "()" when the variable is originally stored ? Alternatively, is there a way I can ensure that "()" is ignored when I perform property checkpoint.

 

Your response is much appreciated.

 

Thank you.

10 REPLIES 10
mikef
Staff

Re: Copying variable

Hi @gdave 

 

Is the project variable being populated by a code or keyword operation in some other test, or manually populated?

To remove characters like this I think you would need to create a small script routine to take the Project variable value and strip the brackets before it checks, like this : 

 

 

def StripBrackets():
      
    aqObject.CheckProperty(Aliases.browser.yourPage.textnode, "contentText", cmpContains, Project.Variables.valueWithBrackets.strip("()"))

 

 

Let me know if this helps or if I can provide another solution perhaps.

 

thanks

Mike

gdave
Regular Contributor

Re: Copying variable

Thanks.

 

The project variable is populated by keyword operation in some other test.

Marsha_R
Community Hero

Re: Copying variable

you can use aqString.Substring to take the middle characters only and skip the brackets at the beginning and end

 

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/substring.html


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
gdave
Regular Contributor

Re: Copying variable

Hi

I am using a keyword test so at what stage & where do I use tis ?

 

Thanks

gdave
Regular Contributor

Re: Copying variable

This is what I have got and somehow I am not able to make it work.

 

qObject.CheckProperty (Aliases.browser.pageTransact.frameMain.formOmView.panel.cell3, 'contentText', 6, ProjectSuite.Variables.TotalWithdrawalAmount_InThisInstruction, true)

 

 

Marsha_R
Community Hero

Re: Copying variable

Is it always 2 places after the decimal?  


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
gdave
Regular Contributor

Re: Copying variable

Yes it is always after 2 decimal places. Thanks

Marsha_R
Community Hero

Re: Copying variable

Marsha_R_0-1621615261183.pngMarsha_R_1-1621615295682.png

My Var1 starts as ($100.23)

 

The first Set Variable Value takes the ( off Var1 and puts the result in Var3

The second Set Variable Value takes the )  off Var3 and puts it back in Var3

 

I would then use Var3 for the Property Checkpoint instead of the Var1

 

 


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
gdave
Regular Contributor

Re: Copying variable

Thanks @Marsha_R 

 

However I get an invalid expression error. Not sure what's wrong with my code here......kindly advise

gdave_0-1621853271176.png

 

cancel
Showing results for 
Search instead for 
Did you mean: