compare strings and perform action - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: compare strings and perform action (/Thread-compare-strings-and-perform-action) |
compare strings and perform action - Forrest Gump - 09-03-2011 Hi All, In run time, I want to compare strings in the datatable and perform action. I have attached the screenshot with the code and datatable in the post. Am also posting code here: Code: Invokeapplication ("E:\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe") Aim: If Column "A" has value "ABC" then QTP must Enter Username and click cancel. If column "A" has value "DEF" then QTP must enter password and click cancel. But according to my code, it is entering Username if strings are same irrespective of data in Column "A". Help me with the logic and also on coding if possible. One of my application runs in similar logic so for better understanding I took Flight Application as example. In my application, I have two Pages: 1. Change Organization (Enter Organization Name i.e column "A" values) 2. Enter values for organization I will enter organization name (one orgnization name) once and then will enter its related data (this will be multiple records). Then will again change Organization name and enter its records. First column will have organization name; similar to the one I posted here i.e in Page1. For Example: If Organization name is "ABC", then QTP must enter data related to column "ABC" If value in Column "A" is changed from "ABC" to other value, say "DEF", then QTP must enter "DEF" in Organization name (i.e., Page1 in my application) and enter data related to column "DEF" (These data will be entered in Page2 of my application) FYI: This action is no way related to my previous posts. Thanks in advance - Gump RE: compare strings and perform action - Ankesh - 09-05-2011 Hi Gump, As per my understanding of the explantion u have given, i must say its better for you to compare the each cell value.. Ur code shld be something like this... Code: a=datatable("A", dtGlobalSheet) i hope this will work. The problem with ur code is that it is not checking for a specific value, it is comparing two strings instead. So whatever the values are in the datatable, if the two rows values are equal, it will enter the userID always. Do let me know if u need further informaton. Regards, Ankesh RE: compare strings and perform action - Forrest Gump - 09-06-2011 Hi Ankesh, Thanks for replying. Am glad that my query is answered after these many days. You understood the problem correctly but not exact way. Code: As per my understanding of the explantion u have given, i must say its better for you to compare the each cell value.. FYI: In my datatable the values such as "ABC" or "DEF" itself will be more than 1000 numbers. If I had to go by your method then I just have to enter those values manually 1000 times to assign it to a variable. I hope you understand what am trying to say. Please do guide me in automating this. Thanks and Regards, - Gump RE: compare strings and perform action - suresz449 - 09-06-2011 Hi Gump, As per my understanding your query the below code will solve your problem. (Before that you have to change settings in File ->Settings->Run->Check Run One Iteration Only) Code: 'Count all rows in Global datatable RE: compare strings and perform action - Rohan - 09-06-2011 Hi gump, here in your case we are taking values from data table and performing actions according to the condition, what the answer given by ankesh is correct, in order to save time you could use select statement. example Code: a=datatable("A", dtGlobalSheet) |