Page 1 of 1

Code for Adding from the dropdown list

Posted: Wed Dec 12, 2018 7:44 pm
by maamer
hello,
i have a problem, i am trying to write a custom code that will take value from user and click on the value in the drop down list to add widget. so far my code is
public static void AddWidget(RepoItemInfo selecttaginfo, string widgetname)
{
var repo = BottomLineIIRepository.Instance;
var widgetbox = repo.DigitalBanking.widgetbox;
var option1 = repo.DigitalBanking.Payees.option;

repo.DigitalBanking.widgetbox.Click(); <-this is clicking the drop down box

option1.Element.SetAttributeValue("label",widgetname); <-here i want to click on the innertext or label of option provided by the user
option1.Click();

}
2018_12_12_13_38_48_BottomLineII_Ranorex_Studio_Administrator_.png
there are 15 widgets so i have 15 test cases. i will use the code in all the test cases to add relevant widget.

please help.

Re: Code for Adding from the dropdown list

Posted: Thu Dec 13, 2018 8:46 am
by odklizec
Hi,

I see you are using Chrome. And the problem is, that Chrome (from all browsers) does not have the individual select list options recognizable by Ranorex (any UI TA tool). It's because of the way Chrome creates the select list. So, there is unfortunately no use for standard "click selectbox -> click desired select option" sequence in Chrome.

What you can do, is to create a repo item pointing to the select tag of your choice, which should have xpath like this (based of the provided snapshot):
/dom[@domain='6012-sbx.btbanking.com']//div[#'SMBHOME']//form[@name='widget-injector-form']/select[@name='widget-injector']
Now you simple add 'Key Sequence' action, targeted to the above select tag. And then add a variable, containing the value you want to select. And that's all. You don't even have to use code :D True, it's not a typical user-like action, but at least this technique works across all browsers! Courtesy of forum member krstcs ;)

Re: Code for Adding from the dropdown list

Posted: Thu Dec 13, 2018 7:45 pm
by maamer
thank you sir.