Mercury WinRunner FAQ
Part:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Q: WinRunner: How to generate user name uniquely?
There are a couple of ways of dealing with this problem. One way is
to maintain a file with the 'last value used' in it and just keep it up
to date. If it's a data driven test, this value could even be in the
data table. Alternately, you can always use the 'time' element as the
value added to your string. That way you're always assured of a new number.
Q: Unable to print a newline character [\n] in file, any solution?
file_printf (<filename>, "%s\r\n", text);
Q: How to define the variable in script that have stored in excel sheet using winrunner?
[In A1 field contains {Class:push button, lable:OK.....}
In B1 field Contains OK = button_press(OK);
where OK contains the value of field A1
OK should act as a variable which has to contain value of field A1]
Answer1:
There is no need to define any variable that is going to use in the
Testscript. You can just start using it directly.
So, if you want to assign a value to the dynamic variable which is taken
from Data Table, then you can use the "eval" function for this.
Example:
eval( ddt_val(Table,"Column1") & "=\"water\";" );
# The above statement takes the variable name from Data table
and assigns "water" as value to it.
Answer2:
Write a function that looked down a column in a table and then
grabbed the value in the next cell and returned it. However, you would
then need to call
button_press(tbl_convert("OK"));
rather than
button_press("OK");
where tbl_convert takes the value from the A1 (in your example) and
returns the value in B1.
One other difficulty you would have would be if you wanted to have
the same name for objects from different windows (e.g., an "OK" button
in multiple windows). You could expand your function to handle this by
having a separate column that carries the window name.
Q: WinRunner: How to Change physical description?
[problem:
the application containes defferent objects , but the
location property is different/changing. Suppose for example, there is one html
table and it contains objects and it's phisical properties,
for one object
{
class: object,
MSW_class: html_text_link,
html_name: "View/Edit"
location:0
}
and for other objects.
{
class: object,
MSW_class: html_text_link,
html_name: "View/Edit"
location:1
}
When record the scripts its gives viwe/edit as logical name,
Code: web_image_click("view/edit", 11, 7);
When run the script win runner cannot identifies which object to click and it
gives an error Msg.
P.S. WinRunner 7.5 with Java and web addins on Windows XP operating system and IE 6.0 browser(SP2).
Answer1:
In dynamically changing the name of the
html_table, we have to interchange the physical description.
while recording the clicked name inside the table will be the name of the
html_table in GUI Map. Change the logical name alone in GUI map.
then in coding using the methods in gui_ get the logical name of this
html_table.get its physical description.delete the Object thru coding from the
Gui map.Then with the logical name and physical description you got previously ,
add these description using Gui_add methods.
Answer2:
Just change the logical names to unique names.
winrunner will recognize each object separately using the physical name and
the location property.
Answer3:
i = 0;
web_link_click("{ class: object, MSW_class: html_text_link, html_name:
\"View/Edit\", location:" & i & "}";
i = 1;
web_link_click("{ class: object, MSW_class: html_text_link, html_name:
\"View/Edit\", location:" & i & "}";
Q: Is there any function in winrunner which will clear the history of the browser?
[Actually the script is working fine when
you execute for the first time. But when you execute in the second
time it is directly going inside the application without asking for
login credentials by taking the path from the browser history. So the
script fails. It is working fine if I clear the history of the browser
before each run. ]
This is not the matter of clearing the history. In any case it should not
allow you to login to application with entering login credentials. I think
this is application bug.
To clear history:
DOS_system with
del "C:\Documents and Settings\%USERNAME%
\Cookies"\*your_cookie\site_name*
Q: WinRunner: How to read dynamic names of html_link
Answer1:
Use the following steps:
1) Using the Function, web_tbl_get_cell_data read the link.
2) use GUI_add function to add to the Map editor.
3) use GUI_save function to save the same link.
4) Now, web_link_click() and pass the variable that you got in step
Answer2:
Can try this method. It will reduce the complexity and there is no
need to update the GUI Map File. Use web_tbl_get_cell_data() function to get the
Description of the link and use the variable name in web_link_click() function.
web_tbl_get_cell_data("Tablename","#Rowno","#columnnumber",0,cell_value,cell_val\
ue_len);
web_link_click(cell_value);
Answer3:
1.get number of row in your table: tbl_get_rows_count
("tableName",rows);
2.write a for loop: for(i=0;i<=row;i++)
3.get text of specified cell with column and row:tbl_get_cell_data
("Name","#"&i,column,var1);
4.compare with the if condition
5.if true : make any flage and take row number in variable m
6.now end the loop and write
tbl_set_selected_cell ( "tableName", "#"& m,column);
type ("<kTab><t2><kReturn>");
Example:
tbl_get_cols_count("Name",cols);
tbl_get_rows_count("Name",rows);
for(i=2;i<=rows;i++)
{
for(j=1;j<=cols;j++)
{
tbl_get_cell_data("Name","#"&i,"#"&j,var1);
if(var1 == Supplier)
{
m=i;
}
}
}
tbl_set_selected_cell ( "Name", "#"&m,"#"&j
type ("<kTab><t2><kReturn>");
Part:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|