![]() |
Reading values form data table - 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: Reading values form data table (/Thread-Reading-values-form-data-table) |
Reading values form data table - new4qtp - 08-02-2010 Hi, When I am trying to read a value from data table, the value is shown in double quotes. eg: value in datatable is - Image When I used this value in my script it is used as "Image",here it is represented as string. I want to use the value same,I mean I would like to use this as - Image How to get the value without quotes. Any help on this.. Thanks, venkat RE: Reading values form data table - guin.anirban - 08-02-2010 Can you put colon (') in the starting of the cell of your datatable and check whether the same is coming? RE: Reading values form data table - new4qtp - 08-02-2010 I have tried by putting the colon in the starting of the cell even though getting the same problem. The retrived value from data table is always treated as string and shown in double quotes. RE: Reading values form data table - guin.anirban - 08-02-2010 Can you put your code here? RE: Reading values form data table - new4qtp - 08-02-2010 My data table is like following, Browser Page type value Login Login Link Help_link Browser,Page,type,value names are column names and the values for those are Login,Login,Link,Help_link I am storing the values in variables, Code: strBrowser = DataTable("Browser","Action1") here i am writing a command using the above values Code: Browser(strBrowser).Page(strPage).strType(strValue).Click When I run the code it fails, because it replace the above line as Code: Browser("Login").Page("Login")."Link"("Help_link").Click Here I need to remove the quotes for Link. Thanks! RE: Reading values form data table - guin.anirban - 08-02-2010 You can not pass the object value like this. I think you are trying to prepare one function for click event for all the objects. You need to pass the entire hierarchy of that object. In your example you are trying to click on the Link object. Link is the name of the class and you have to explicitly define it into your script. RE: Reading values form data table - PrabhatN - 08-02-2010 Hi new4qtp, Anirban is right. Link is the name of the class and you have to write it in your script. And the way you are passing values to Browser, Page or Link doesn't work. You have to specify the properties for which you are storing the values in the data table. Try to analyze the following, Lets take the Google page as our example. Suppose you want to click through the "Gmail" link in the Google page. The hierarchy to which we need to follow is like: Browser().Page().Link().Click Here for "Browser" and "Page" object, we have several properties like "name","title" etc. and for Link object we have "name" as a property along with many more. Suppose you have stored the "name" of the Browser,Page, and Link object in your DataTable under "Browser","Page" and "Link" columns respectively. Then retrieve the values like: Code: BrowserName = DataTable("Browser",dtLocalSheet) Now you can write like: Code: Browser("name:="&BrowserName).Page("name:="&PageName).Link("name:="&LinkName).Click Note that here you are explicitly providing the object class and property and providing only values from the DataTable. For this example, Browser and Page name is "Google" and Link name is "Gmail" Hope you can understand now. RE: Reading values form data table - new4qtp - 08-02-2010 Hi Prabhath, Thanks for the detailed info. Now I am writing the code like follows and achieve the things, Case "Link" Code: Browser("name:="&BrowserName).Page("name:="&PageName).Link("name:="&LinkName).Exist Case "WebElement" Code: Browser("name:="&BrowserName).Page("name:="&PageName).WebElement("name:="&LinkName).Exist Using the above code checking the UI elements on the page not performing any actions. Is this right approach? Thanks, Venkat RE: Reading values form data table - PrabhatN - 08-02-2010 Hi Venkat, I did not get what exactelly you want to do. Can you please elaborate what do you mean by "checking UI elements on the page not performing any actions". But according to my personal view, this is not the way things are/should be done, because you cann't retrieve all the values from DataTable and use it when your test is considerably larger. This is why we have something called "Automation Frameworks" where things are done in a nice approach. |