Forum Discussion
- rraghvaniChampion Level 3
Can you provide screenshots, of what you have done so far? So that we can get a better understanding
- gshaikhOccasional Contributor
Hi rraghvani please see screenshot below.. on step 1 i am trying to create Global variable using script routing AddVariable()
in second step i want to assign value of property 'title' to variable using run code snippet from an mapped object 'Aliases.browser.page_Search_Lightning.link_firstResultLink'
I was trying something like below
Project.Variables.VariableByName["Coveo_FirstLinkName"] =Aliases.browser.page_Search_Lightning.link_firstResultLink.contentText;
but its giving syntax error
hope this information will help.
- rraghvaniChampion Level 3
In Keyword Testing, you have the option to create a variable,
You can specify a constant value to the variable,
and use Log to output the value,
In JavaScript code, you can assign the variable like so,
and in your Keyword Test call the routine to assign the variable, and again use Log to output the value,
- gshaikhOccasional Contributor
Hi rraghvani,
Issue with creating an local variable in keywordtest is if we use same keyword test multiple times in an test run it retains previous value..so i am trying to create and remove variable after running the specified keyword test.
hence i want an solution how i can assign value to dynamically created variable from an Object property.
- rraghvaniChampion Level 3
Here's an example using JavaScript code of assigning an object (Page Object) to a variable (var page), which is then used to find a button using the extended method (FindElement)
var page = Sys.Browser("chrome").Page("https://www.w3schools.com/css/css3_buttons.asp"); var button = page.FindElement("//button[.='CSS Button']");
It's not necessary to delete a variable, you can assign an empty value to it instead. You can then check, if it's an empty value, assign a value to it. Perform the necessary steps, then set the variable to an empty value once finished.
Code example,
If you don't assign an empty value to Var1, the previous value is stored shown in Local Value. Assigning Var1 to "Good Bye World" will not work.
You need to ensure your logic is correct
Related Content
Recent Discussions
- 2 days ago
- 2 days ago
- 5 days ago