51Testing软件测试论坛

标题: WinRunner:Testing with Unique Usernames [打印本页]

作者: pcl2004_27    时间: 2006-10-25 14:10
标题: WinRunner:Testing with Unique Usernames
Description

      Running a web test that requires a unique username each time its run.


Solution

      My answer was:
To get a 'unique' name the following function should help. It is dependant on the system time but should be
different for every second unless execution should happen at an exact time.

##sample script begins
#The function that returns a user name and a number (time) appended to it
public function n_user_name(in text){
return (text&get_time());
}




#The sample code starts here
#in this sample the name 'john' is being passed into the function
#the variable 'name' then holds the new value returned back from the function
#the variable 'name' has john and a number behind it
for(i=0;i<5;i++){
name=n_user_name("john");
print(name);
wait(1);
}
##sample script ends




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2