cancel
Showing results for 
Search instead for 
Did you mean: 

Set value to Project variable of object type

New Contributor

Set value to Project variable of object type

I am trying to use Project variable of object type to store my object name mapping. But after I create the project variable of object type, I am not able to assign a value. I am getting an error "The variable of the object type cannot be edited"?

 

Please help me to fix this.

 

Thanks,

Umakant

5 REPLIES 5
Highlighted
Community Leader

Re: Set value to Project variable of object type

Hi

 

You can't do this in project variables inside IDE, but you can easily add value in script routine.

 

  let obj = Project.Variables.Var1 = {param: "val", param2: "val2"};
Highlighted
New Contributor

Re: Set value to Project variable of object type

@Wamboo Thanks for your response.

 

Here is what I am trying to do

1. I have a object reference (Aliases.browser.pageSvl005epicno301EcmcLan8443Ep2) in my script routine 

2.  I would like to store it in Project Variable for Object type

3. Like you mentioned 

let obj = Project.Variables.Var1 = {param: "val", param2: "val2"};

what does param: "val" referring to here. I am  not sure about it? Please help me understand it.

 

Thanks,

Umakant 

Highlighted
Community Hero

Re: Set value to Project variable of object type

Basically, object type variables can only be assigned in code.  So, you would have to do an assignment like

 

Project.Variables.Var1 = Aliases.browser.pageSvl005epicno301EcmcLan8443Ep2

You can't assign it ahead of time.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Community Leader

Re: Set value to Project variable of object type

Hi,
the 'val' it's the value you want to assign to object property. In my example you have a custom object which you want to fill with data from test routine.

 

Check this website if you want to learn more about JS objects:

 

https://www.w3schools.com/js/js_object_definition.asp

Highlighted
Community Manager

Re: Set value to Project variable of object type

Thanks for the suggestions, guys!

@umakant , did you find the solution? Please share it with us.

 

 

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors