Not able to select value from dropdown

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 31
Joined: Mon Feb 22, 2016 7:21 pm

Not able to select value from dropdown

Post by vivek.guvva » Thu Mar 31, 2016 8:12 pm

Hi, I have a dropdown with 7 values. When ever, I am trying to select a value from dropdown by using a parameter in xpath for the value, It is always selecting the first value from dropdown. If i use exact value instead of parameter in the xpath, it is selecting the exact value. The problem is when I include a parameter in the xpath. I have the xpath and function below. Please help me in resolving this.

MetricSelection = body//ul[@class='x-list-plain']/li[@innertext~'Digital Album'] -- This is working

MetricSelection = body//ul[@class='x-list-plain']/li[@innertext~$objMetricName] -- Always selecting the first value from dropdown if i use this xpath with parameter instead of exact value (I am passing the parameter value as an argument to the function.

Public Shared Sub SelectMetric(objMetricName as String)
report.Log(reportlevel.Success, "Metrics dropdown button is clicked")
If repo.MediaViewQC.MetricSelectionInfo.Exists Then
report.Log(reportlevel.Success, SelectedMetric & "Metric is selected")
report.Log(reportlevel.Failure, "Metric is not selected")
End If
report.Log(reportlevel.Failure, "Metrics dropdown button is not clicked")
End If
Catch e As Exception
report.Log(reportlevel.Failure, "Not able to select metric")
End Try
End Sub

User avatar
Ranorex Guru
Ranorex Guru
Posts: 7469
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: App get crashed while tap on element in iOS Instrumented app

Post by odklizec » Thu Mar 31, 2016 9:22 pm


The problem is that the $objMetricName repo variable used in repo item xpath is most probably not filled with expected value (Digital Album). Passing the variable to function is not enough to fill the repo element variable. I'm sure that if you check the MetricSelection xpath (within the SelectMetric function) it will show empty li tag innertext. And this is also the reason why it selects first item in dropdown. If you try the xpath with empty li tag innertext in spy, it will return all dropdown items. But Ranorex can (and will) click only the first one. What you need to do is to bind the repo variable with data connector.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Posts: 31
Joined: Mon Feb 22, 2016 7:21 pm

Re: Not able to select value from dropdown

Post by vivek.guvva » Mon Apr 04, 2016 4:42 pm

Thank you, It's working when I am passing the parameter through excel data connector.