Code condensing - 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: Code condensing (/Thread-Code-condensing) |
Code condensing - joncfrazier - 05-15-2012 1) Is there a faster (i.e. shorter) way to accomplish this code, or is this the most condensed method? 2) Even if not more condensed, is there a better way? 3) Is there a way to compare values while ignoring empty space and being case insensitive? The code compares text fields on a web page with values in a datatable. As the parameterized test goes down, it compares each row with the values in the text field. Only the zprod value is entered into a text field, while the xprod value is autofilled out by the web page. Code: xprod = Browser("...").Page("...").WebEdit("txtName").GetROProperty("value") RE: Code condensing - Shridevi.Salagare - 05-16-2012 Hi, If you want to compare multiple values I would suggest you to use Dictionary object. And to avoid spaces you can use Trim function and to make the comparision case insensitive you can use lcase or Ucase on both the values to be compares that way it will convert the value in lower case or upper case and you can compare them. let me know if u have any queries regarding this. RE: Code condensing - joncfrazier - 05-16-2012 I've looked at Dictionary objects before, but I'm not really clear on where to put the code (some have placed the code in a function library), I'm also not too clear on the benefits of using it (over what is listed here), or how I would compare objects using it. For simple item creation, i could write "x = [whatever]" or for a dictionary I'd have to write: Dim x Set x = [whatever] and then some items here which I don't know their use. So the dictionary term becomes quite longer than the simple "x = y" As for trim and ucase, would this be the correct method? Code: xprod = Trim(UCase(Browser("...").Page("...").WebEdit("txtName").GetROProperty("value"))) That doesn't seem quite right. |