Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Select From List
#1
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi All,
In an interview interviewer asked me one question, i could not ans. that. I am posting that question here and hope that i will get correct answer.

Scenario: You have two list box. In one list contains state name and second list contains district name.

Question: What would be your approach or code If i chose one state from state list then district list should display all the district for that particular state[/b].
Reply
#2
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi,
Les take this scenario,
By selecting State1 from state list then District1, district2, district3 has to dispaly

1. m=First select state1 from state
2.n=Get the all items displayed under district list i.e Getroproperty("all items") (Note: It will display with any delimeter like district1;district2;district3) (usually developers will display with any delimeter)
3. All item consists of then split the total items with ; delimeter
4. Use the if else condition like
if (m=n)
use reporter event with pass
else
reporter event with fail
End if

This is the way u have to proced...
Please let me know if u need any information apart from this...
Reply
#3
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi Venkat,
I think your logic needs to be modified a bit.
in your fourth statement , you are comparing state with the district i.e - m = n, right?
this is of no use.
rahul1234 -You must have the expected data list for state and respective district prepared in order to verify the district list.
First You will have to keep all the state and district in an excel can be imported in datattable.
then select a state, get all the items in your district list.
get all the districts from the xls for the state selected
verify all the districts are there in the list or not.

let me know if there is any issue.

Reply
#4
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi Saket,
Thanks for updating me about that,
i have modified and keeping the logic here

Code:
Browser("xxxxxxxxxx").Page("xxxxxxxxxx").Frame("main").WebList("p_states").Select("State1")
pvalue=Browser("xxxxxxxxxx").Page("xxxxxxxxxx").Frame("main").WebList("p_states").GetROProperty("selection")
cvalues=Browser("xxxxxxxxxx").Page("xxxxxxxxxx").Frame("main").WebList("p_districts").GetROProperty("all items")
If pvalue="State1" and cvalues="* None *;District1;District2;District3" Then
    Reporter.ReportEvent micPass,"For the selecting state1 in state list","Which is showing as expected"
    else
    Reporter.ReportEvent micFail,"For the selecting state1 in state list","which is not showing as expected"
    msgbox "Fail"
End If
Please find the attached screen shot document...

Please let me know if u need any information apart from this...


Attached Files Image(s)
       
Reply
#5
Solved: 10 Years, 8 Months, 2 Weeks ago
That's great you have got a similar application. Smile
I am sure this will definitely help to rahul1234.

Reply
#6
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi Saket,
This is not my application which i have developed all this things in my product and developed script
mine is product based application thats the reason i have developed....
Reply
#7
Solved: 10 Years, 8 Months, 2 Weeks ago
Thanks thanks a lot to Saket and Venkat.
That solve my problem. Thanks for your reply and great work.
Reply
#8
Solved: 10 Years, 8 Months, 2 Weeks ago
Hey Rahul,
Thanks alot...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)