cancel
Showing results for 
Search instead for 
Did you mean: 

FindChild : Error: The object does not support this property or method

SOLVED
Highlighted
New Contributor

FindChild : Error: The object does not support this property or method

Hello,

I tried to refactor my code with this below function, but i get the error in subject, when i try to access FindEx from Project.Variables.objstudioprocess

When I set a breakpoint at this line, and evaluate with debugtool:
Project.Variables.objstudioprocess   returns an 'Object'

That i can inspect and see the FindEx method available

When i try to evaluate with debugtool: 

Project.Variables.objstudioprocess.FindEx(propArray,propValues,depth=5,true,delay = 5000) 

It indeed find the tested object that i want.

When I continue the execution of the test it raises again the error.

See below the code : 

function addNewProjectVariable(parentName, variableName, type, arrayNames, arrayValues) {
if (!Project.Variables.VariableExists(variableName)) {
Project.Variables.AddVariable(variableName, type);
}
let propArray = arrayNames;
let propValues = arrayValues;


Project.Variables.variableName = Project.Variables.objstudioprocess.FindEx(propArray,propValues,depth=5,true,delay = 5000) // Error: The object does not support this property or method.
Log.Message("systemView :"+Project.Variables.projectTreeView.Name)

}
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: FindChild : Error: The object does not support this property or method

To answer your question:

 

Project.Variables.variableName is not defined because there isn't a variable named variableName.  There is a variable with the name that is the content of variableName.  

 

So, let's say variableName is "myVariable".  Then you would reference it as Project.Variables.myVariable or Project.Variables.VariableByName("myVariable").

 

Now, as to the other issue, this might be because you're using JavaScript and JavaScript can't assign values to indexed properties directly.  So, you'll need to re-do that line like so.

 

function addNewProjectVariable(parentName, variableName, type, arrayNames, arrayValues) {
  if (!Project.Variables.VariableExists(variableName)) {
    let localVariable = Project.Variables.AddVariable(variableName, type);
  }  // Variable is created / evaluated here already 
else {
    let localVariable = Project.Variables.VariableByName(variableName);
}
  let propArray = arrayNames;
  let propValues = arrayValues;
  
 localVariable = Project.Variables.objstudioprocess.FindEx(propArray,propValues,depth=5,true,delay = 5000)
  Log.Message("systemView :"+Project.Variables.projectTreeView.Name)
  
}

 

Alternatively, you may need to use the $set method to assign the variable value.


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

View solution in original post

5 REPLIES 5
Highlighted
Community Hero

Re: FindChild : Error: The object does not support this property or method

I think the problem is here.

 

Project.Variables.variableName = Project.Variables.objstudioprocess.FindEx(propArray,propValues,depth=5,true,delay = 5000)

 

What is "variableName" in this context?  The code doesn't know.  You've created a variable with the NAME that is stored in variableName, but that variable isn't evaluated yet.

 

instead, replace with

 

Project.Variables.VariableByName(variableName) = Project.Variables.objstudioprocess.FindEx(propArray,propValues,depth=5,true,delay = 5000)

 You need to use "VariableByName" because you need to evaluate what the variable is by the given name.  This is where your error is coming from, not the find.


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
New Contributor

Re: FindChild : Error: The object does not support this property or method

Hello!

Actually,
to your question : What is "variableName" in this context?

 

function addNewProjectVariable(parentName, variableName, type, arrayNames, arrayValues) {
  if (!Project.Variables.VariableExists(variableName)) {
    Project.Variables.AddVariable(variableName, type);
  }  // Variable is created / evaluated here already 
  let propArray = arrayNames;
  let propValues = arrayValues;
  
 Project.Variables.VariableByName(variableName) = Project.Variables.objstudioprocess.FindEx(propArray,propValues,depth=5,true,delay = 5000)
  Log.Message("systemView :"+Project.Variables.projectTreeView.Name)
  
}


See in my function i have a first part that deals with VariableName creation, isn't it already evaluated then ?

if (!Project.Variables.VariableExists(variableName)) {
    Project.Variables.AddVariable(variableName, type);
  }  // Variable is created / evaluated here already 



I tried your solution still : I got a new error 
ReferenceError: Invalid left-hand side in assignment 

Highlighted
Community Hero

Re: FindChild : Error: The object does not support this property or method

To answer your question:

 

Project.Variables.variableName is not defined because there isn't a variable named variableName.  There is a variable with the name that is the content of variableName.  

 

So, let's say variableName is "myVariable".  Then you would reference it as Project.Variables.myVariable or Project.Variables.VariableByName("myVariable").

 

Now, as to the other issue, this might be because you're using JavaScript and JavaScript can't assign values to indexed properties directly.  So, you'll need to re-do that line like so.

 

function addNewProjectVariable(parentName, variableName, type, arrayNames, arrayValues) {
  if (!Project.Variables.VariableExists(variableName)) {
    let localVariable = Project.Variables.AddVariable(variableName, type);
  }  // Variable is created / evaluated here already 
else {
    let localVariable = Project.Variables.VariableByName(variableName);
}
  let propArray = arrayNames;
  let propValues = arrayValues;
  
 localVariable = Project.Variables.objstudioprocess.FindEx(propArray,propValues,depth=5,true,delay = 5000)
  Log.Message("systemView :"+Project.Variables.projectTreeView.Name)
  
}

 

Alternatively, you may need to use the $set method to assign the variable value.


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

View solution in original post

Highlighted
Community Hero

Re: FindChild : Error: The object does not support this property or method

@dicas 

And one more question:

 

Is it *really* needed to store a reference to the objstudioprocess process in the project variable?

Why not just use Aliases.objstudioprocess instead?

 

Regards,
  /Alex [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
================================
Highlighted
Community Manager

Re: FindChild : Error: The object does not support this property or method

Thank you everyone!

 

@dicas was the advice helpful? Please let us know!


Sonya Mihaljova
Community and Education Specialist
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
A new challenge is here!

Create a function to drag one element to another for the TechCorner tag!

Will you dare to take the challenge?


Scripts created in July:
- Passing custom command-line arguments as a test parameter
Top Kudoed Authors