![]() |
Identifying radio buttons with same html ID but dynamic webelement properties - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming) +--- Thread: Identifying radio buttons with same html ID but dynamic webelement properties (/Thread-Identifying-radio-buttons-with-same-html-ID-but-dynamic-webelement-properties) Pages:
1
2
|
Identifying radio buttons with same html ID but dynamic webelement properties - manishac - 04-20-2012 Hi, I am working on an application where I need to answer a set of questions that have radio buttons for answer selection. the html id is the same for two questions that appear on the screen in two different scenarios. I am using Object repository and assigned the object the same name as on the screen, hence, whenever a different scenario is executed, the script fails because it is identifying the object using the logical name in OR. for eg: In scenario 1: webelement is Question 1 has A and B as the radio buttons and the html id is Question_1_id in scenario 2: webelement is Question 2 has an A and B as radio buttons and the html id is Question_1_id I named the object with Question_1_id as "Question1" in the OR hence, when the script is executed for scenario 2 , it is failing since it is looking at text for "Question 1". Browser("aa").page("aa").webradiogroup("Name:=Question1", "html id:= Question_1_id").select parameter("answer") /parameter answer has A or B Please let me know if there is a solution! Thank you very much! RE: Identifying radio buttons with same html ID but dynamic webelement properties - sshukla12 - 04-20-2012 Hi, Approach u have followed is very correct. Instead of adding n no. of objects with different name , just add a single object. To overcome ur problem first count the number of questions in ur web page let say it is stored in a variable vr_QCount Code: for i=1 to vr_QCount Give it a try and let me know if its works 4 u or not. Regards, Sankalp RE: Identifying radio buttons with same html ID but dynamic webelement properties - Shridevi.Salagare - 04-20-2012 First for checking the Object in OR. Check wheteher the same object is highlighted for both question 1 options and Question 2 options. If the object is not same then you have to add both the object. Correct me if I am wrong. RE: Identifying radio buttons with same html ID but dynamic webelement properties - manishac - 04-20-2012 Hi Sankalp, Thanks a lot for your response. Wanted to ask if I can work around without using the name property because the text (webelement) is different in every scenario. for eg: question_1_id is the html id for webelement "what is your name" in scenario 1 and " country residing in" in scenario 2. Also I found that there is a source index native property that is unique for every webelement that share the same html id. Is there a way to use that property to identify the object using DP? Please let me know if you have some examples.Thanks again! Regards Manisha RE: Identifying radio buttons with same html ID but dynamic webelement properties - sshukla12 - 04-23-2012 Hi Manisha, U can use index property to give a try. it would be really good 4 me 2 understand the situation if u can provide the snapshots. Regards, Sankalp RE: Identifying radio buttons with same html ID but dynamic webelement properties - manishac - 04-24-2012 Hi, Here is the sample snapshot from the record and playback of the application. In scenario 1, when I click link A, I have to answer 4 questions with html ids as shown in the snapshot and the value in the select statement is hard coded and does not change. When I execute scenario 2, some of the questions from scenario 1 appear but with different html id, and they are assigned the html ids in the order that they appear on the screen. Please see screenshot and let me know if you need more info. Thank you! Regards Manisha RE: Identifying radio buttons with same html ID but dynamic webelement properties - sshukla12 - 04-24-2012 Hi Manisha, U can follow the below approach, its a generic approach and can handle the n number of question in n number of scenarios 1) Create a .xls file containg the questions and their respective answers.(attached is the .xls for refrence) 2) Load the .xls to ur global or local data table. 3) Count the number of questions in a given scenario(U can use DP), store it in a variable say vb_QuesCount 4) Start a for loop for the number of questions in a scenario 5) Using the GetRoProperty find the name of first element (name of 1st question since u are using DP it won't be a problem),vb_QuesText 6) Search through the 1st column of the datatable where .xls is loaded and check if question exists in datatable or not. 7) If question exists then get the answer value for that particular question from datatable say in variable vb_Ans Code: Code: Set Dp=Description.Create() Hope this helps u, let me know in case of any issues. Regards, Sankalp RE: Identifying radio buttons with same html ID but dynamic webelement properties - manishac - 04-25-2012 Hi Sankalp, Can you attach the.xls file again which you mentioned in step 1. Thanks Manisha RE: Identifying radio buttons with same html ID but dynamic webelement properties - sshukla12 - 04-25-2012 [attachment=975][attachment=975][quote='manishac' pid='20816' dateline='1335293197'] RE: Identifying radio buttons with same html ID but dynamic webelement properties - manishac - 04-26-2012 Hi Sankalp, In order to search the vb_questext in the datatable column, can I use strcmp function? can u please post a sample code for that? Regards Manisha |