What is the best way to automate Dropdown which have lot of values to select (Eg: State Dropdown)
Can anyone suggest me:
1. how can i automate State dropdown which have lot of values to select (By Using TestComplete and JavaScript)
As of now i have created object of some values and clicking on them in a simple way. But it's not convenient.
I want to select one state (Which I want to pick from Excel File) from State Dropdown.
2. Is there any way to select the value from dropdown after getting the list of values with Find Element. (Like we do
most of the time in selenium)
Eg of selenium:
List L = Dropdown.findElemets (.......................);
L.selectByName ("Pass the name of the value that you wanna select from the Dropdown");
Like this, is there any way to do so with Test Complete Also?????
1. For native web dropdown controls (even for Scalable Web Testing) the code will be:
function test() { Sys.Browser("chrome").ToUrl("https://material.angular.io/components/select/examples"); Sys.Browser("chrome").Page("https://material.angular.io/components/select/examples").FindElement("//select[@id=(//label[.='Cars *']/@for)]").ClickItem("Audi"); }
So, maybe the control which you use is not supported one.
In this case you can request support of this control in the special section for feature Ideas: https://community.smartbear.com/t5/TestComplete-Feature-Requests/idb-p/TestXCompleteFeatureRequests
2. 3. 4. Unfortunately, I have no access to your web page, but it seems, yes, it's not simple drop-down. That's how it's possible to deal with controls without special support:
function Test1() { let URL = "https://material.angular.io/components/select/overview"; let whattoclick = "'Pizza'"; Browsers.Item(btChrome).Navigate(URL); let browser = Sys.Browser(); browser.BrowserWindow(0).Maximize(); let page = browser.Page(URL); page.FindElement("//select-overview-example/mat-form-field//mat-select//span[contains(@class, 'mat-select-placeholder')]").Click(); page.FindElement("//span[contains(text(), "+whattoclick+")]").Click(); }
lets try to do it like this:
WhatToClick = "'"+excelSheet.Cell("A", 3).Value+"'"
put single quote before and after the WhatToClick