Select an item/link from dropdown list using passing variable..
Hi,
Can someone please assist. I'm trying to select an item from dropdown list using passing variables. The variables are Link(0) and TextNode(0) which I'm trying to pass data from spreadsheet.
FullName:
Aliases.browser.Page("https://www.ukbusstage.com/tickets/megarider").Panel(0).Panel(3).Panel(0).Panel(0).Panel(4).Panel(0).Panel(0).Panel(0).Panel(1).Panel(0).Form(0).Panel(0).Panel(0).Panel(1).Panel(0).Panel(1).Panel(0).Link(0).TextNode(0)
MappedName:
Aliases.browser.pageMegariderTicketsForTheUk.panelPageWrapperPageWrapperTicke.panelWrapperWideWrapperBody.panelRowLocationUnknownHidden.form.panelLocationAutocompleteFieldRo.panelLocationSearchContainer.panelResults.linkMegarider.textnodeGlasgowGlasgowCity
My attempted code is as below but still unable to select the intended item:
Aliases.browser.pageMegariderTicketsForTheUk.panelPageWrapperPageWrapperTicke.panelWrapperWideWrapperBody.panelRowLocationUnknownHidden.form.panelLocationAutocompleteFieldRo.panelLocationSearchContainer.panelResults.linkMegarider.TextNode(DDT.CurrentDriver.Value("Sub Location")).click();
Please see the attached screen for more details !!
Thanks and Regards,
Az Margani.
What is in the value of DDT.CurrentDriver.Value("Sub Location")?
That is, possibly, the key to the problem. The parameter passed to TextNode(0) probably has to be numeric. What you need to do is use a FindChild call of some sort on your component on the drop down that, after you click on the dropdown, you search the resulting component to find the text node you want based upon a text string you are passing in. Whatever object is returned on that FindChild call, execute the ClickMethod.
So, your code should be something like:
MyNode = Aliases.browser.pageMegariderTicketsForTheUk.panelPageWrapperPageWrapperTicke.panelWrapperWideWrapperBody.panelRowLocationUnknownHidden.form.panelLocationAutocompleteFieldRo.panelLocationSearchContainer.panelResults.FindChild("innerText", DDT.CurrentDriver.Value ("Sub Location")); MyNode.Click();
This code is, obviously, not tested since I am not actually accessing your site. The list of properties and their values will need to be determined by the actual components in question but that should give you the general idea of what to try.