Script Extenson: All Parameters are Undefined
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Script Extenson: All Parameters are Undefined
I'm creating my first script extension and I'm running into a serious wall with the Parameters object.
I have this code:
function AdvWait_OnCreate(Data, Parameters) { Parameters.URL = "hello.world"; } function AdvWait_OnExecute(Data, Parameters) { Log.Event(Parameters.URL); }
I would expect this to result in a log event with the title "hello.world", but the title is blank. If I try to put Parameters.URL in the Additional Info section of the log, it prints as "undefined". The code otherwise seems to work, but it's no use if I can't access or use my parameters.
If it helps, this is my description file:
<ScriptExtensionGroup> <Category Name="Keyword Test Operations"> <ScriptExtension Name="Advanced Wait" Version="0.1"> <Description>Pauses the script for a set time until the page loads.</Description> <Script Name="AdvWait.js"> <!-- Specify the script file name here --> <KDTOperation Name="Advanced Wait" Category="Test Actions"> <Parameters> <Parameter Name="URL"/> </Parameters> <Columns> <Column Name="Item" Value="Advanced Wait" /> <Column Name="Value" Editable="True" EditorType="Parameters" /> </Columns> <Events> <Event Name="OnCreate" Routine="AdvWait_OnCreate" /> <Event Name="OnExecute" Routine="AdvWait_OnExecute" /> </Events> </KDTOperation> </Script> </ScriptExtension> </Category> </ScriptExtensionGroup>
Both have been cut down significantly, but this problem persists whether I have one parameter or a dozen. Any help would be appreciated.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think default parameter values only apply if you actually have a custom user defined form, otherwise it just uses the basics from the default wizard. Do you have a User Form defined and included in your extension?
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, right. I don't have a user form.
However, in testcomplete, when I create or edit an instance of this operation (with this OnSetup method I forgot to include the first time) ...
function AdvWait_OnSetup(Data, Parameters) { return true; }
<Event Name="OnSetup" Routine="AdvWait_OnSetup" />
... the operation parameters screen opens and I can see that they've been set by the OnCreate function (see attachment). Is this not representative of the real data in the operation?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've created a user form and the requisite code for setting Parameter values, but that hasn't changed anything.
function AdvWait_OnSetup(Data, Parameters) { var frm = UserForms.AdvWaitForm; frm.textURL.Text = Parameters.URL; // Display the Operation Properties dialog and check the results if (frm.ShowModal() != mrOk) { return false; // No changes were made } Parameters.URL = frm.textURL.Text; return true; }
With that code, I can set the form data and see the new url in the operation perameters screen, or change it in the operation perameters screen and see the change in the form data next time it opens.
But this code:
function AdvWait_OnExecute(Data, Parameters) { Log.Event(Parameters.URL); }
... still produces a log with a blank title, or the text "undefined" if printed in additional info. I don't understand the problem here.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you upload your extension that you are working with? I'd like to play with this and see if I can figure out what's up.
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you have one that functions? This one is missing the icon file for the operation.
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK... with that, when I drag the operation over, I first get prompted to enter the URL. Whatever I type in there, gets input into the operation and the test runs.
Is this not the behavior you're seeing?
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The operation runs, but it's supposed to create a log entry with the input URL (Parameters.URL, as in the OnExecute function) as its title. Whenever I try this, the title is blank. If the URL is printed out in the "additional info" section of the log, it prints as "undefined" no matter what the URL actually is. I can't seem to perform any operations on any parameters, even integers and booleans, because they're somehow undefined despite the data clearly existing within the program.
