Forum Discussion
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.
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
- 5 years ago