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)
Try
repo.MediaViewQC.MetricsDropdown.EnsureVisible
repo.MediaViewQC.MetricsDropdown.Click
report.Log(reportlevel.Success, "Metrics dropdown button is clicked")
If repo.MediaViewQC.MetricSelectionInfo.Exists Then
repo.MediaViewQC.MetricSelection.Focus
repo.MediaViewQC.MetricSelection.Click
report.Log(reportlevel.Success, SelectedMetric & "Metric is selected")
Else
report.Log(reportlevel.Failure, "Metric is not selected")
End If
Else
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")
throw
End Try
End Sub
Not able to select value from dropdown
Re: App get crashed while tap on element in iOS Instrumented app
Hi,
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.
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 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
Thank you, It's working when I am passing the parameter through excel data connector.