Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Identifying radio buttons with same html ID but dynamic webelement properties
#1
Not Solved
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!
Reply
#2
Not Solved
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
Browser("aa").page("aa").webradiogroup("Name:=Question"&i, "html id:= Question_1_id").select
Next

Give it a try and let me know if its works 4 u or not.

Regards,
Sankalp
Reply
#3
Not Solved
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.
Reply
#4
Not Solved
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
Reply
#5
Not Solved
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
Reply
#6
Not Solved
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


Attached Files Image(s)
   
Reply
#7
Not Solved
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()
Dp(xx).Value=??(create description for webRadioGroup)
Vb_quesCount=Dp.Count
For i=1 to vb_quesCount
vb_QuesText=Dp(i).GetRoProperty
‘Code to search the vb_QuesText in datasheet and if exists( This U can do it ur self)

Browser(x).Page(y).webRadioGroup (‘Name :=’&vb_QuesText,’html id:=Question[‘&i&’].Answer.Id’).Select vb_Ans
Next


Hope this helps u, let me know in case of any issues.

Regards,
Sankalp
Reply
#8
Not Solved
Hi Sankalp,
Can you attach the.xls file again which you mentioned in step 1.

Thanks
Manisha
Reply
#9
Not Solved

.doc   Question.doc (Size: 26.5 KB / Downloads: 140)
.doc   Question.doc (Size: 26.5 KB / Downloads: 140) [quote='manishac' pid='20816' dateline='1335293197']
Reply
#10
Not Solved
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to identify a Dynamic WebElement? PreethiJoshi 1 5,537 05-03-2018, 04:08 PM
Last Post: Ankur
  Dynamic obj rep - get text in the class (html) marcio cravo moreira 0 2,127 05-26-2015, 06:58 PM
Last Post: marcio cravo moreira
  Radio Button vinod123 8 10,619 09-25-2014, 12:12 PM
Last Post: vinod123
  Radio Group problem vinod123 4 5,793 09-25-2014, 12:10 PM
Last Post: vinod123
  not identifying the object properties seven 3 2,742 02-18-2014, 04:23 PM
Last Post: supputuri

Forum Jump:


Users browsing this thread: 1 Guest(s)