Contributions
Re: Select method (JS) to select something from drop-down list
I found here a solution using native JS. This HTML code <select id='mydropdown'> <option value='foo'>Spam</option> <option value='bar'>Eggs</option> </select> JS solution var desiredValue = "eggs" var el = document.getElementById("mydropdown"); for(var i=0; i<el.options.length; i++) { if ( el.options[i].text == desiredValue ) { el.selectedIndex = i; break; } } For the ClickItem() , I found something here TestObj.ClickItem(Item, Shift) TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section Item [in] Required Variant Shift [in] Optional TShiftKey Default value: skNoShift Result None function Main() { var p, w, ListBox; // Obtain list box object p = Sys.Process("wordpad"); Sys.Keys("~i[Enter]"); w = p.Window("#32770", "Date and Time"); ListBox = w.Window("ListBox", "", 1); // Select the specified item ListBox.ClickItem(6); } I may be wrong, but I assume ClickItem() can only be used with Test Object from Object Browser / Name Mapping only ? Not a Test Object from Page.QuerySelector ("CSS Selector Path") ? Thanks.6.2KViews0likes1CommentRe: Select method (JS) to select something from drop-down list
But in TestComplete using Javascript, I cannot write something like this:smileyhappy: Select s = new Select(driver.findElement(By.xpath("//path_to_drop_down"))); That syntax is Java Selenium Webdriver syntax. I don't think I can put Java Selenium syntax in TestComplete JS ? :smileyhappy: :smileyhappy:6.2KViews0likes1CommentRe: Select method (JS) to select something from drop-down list
Thanksshankar_rfor the example. I found the documentationpretty confusing. After seeing your example , it looks pretty simple actually:smileyhappy: s.ClickItem("<index of the item> or <"Name of the item">") BTW, of what type is s ? Can s be like this ? let s = Page.QuerySelector ("CSS Selector Path"); s.ClickItem("<index of the item> or <"Name of the item">") MKozinetsCould the documentation be elaborated a little bit maybe? With some examples? Thanks :smileyhappy:6.2KViews0likes3CommentsSelect method (JS) to select something from drop-down list
Hi, In Selenium Java, we can have this code here to select something from drop-down list : Select s = new Select(driver.findElement(By.xpath("//path_to_drop_down"))); s.selectByVisibleText("Value1"); s.selectByIndex(5); Just wondering, if we have some similar thing in TC using JavaScript to selectsomething from drop-down list ? Thank You.Solved6.3KViews0likes7CommentsName Mapping - Map Child Objects - Selecting Properties
Hi, I have mapped a parent object in name mapping, then I right click that parent --- choose Map Child Objects That parent has 50 children. I don't want to manually map it, so I tick that option Automatically map children (or something like that) and TC will map all children. The problem with automatically map children is that TC doesn't select the properties that I need. TC just selected ObjectTypeproperty meanwhile I would like to have innerHTML , innerText , etc properties. How can I tell TC to automatically map all those 50 children and select all those properties that I want ? Manually map it and choose the property for each child would take a lot of time. Secondly, if I don't selectinnerText property in NameMapping , in my JS script can Iwrite like this? var props = ["innerText"]; var values = [Test2]; var depth = 0; var day = parent.FindChild(props, values, depth); Thank You.1.2KViews0likes2CommentsRe: Finding Child and its property value in the DOM
I think I found the answer here https://support.smartbear.com/testcomplete/docs/scripting/specifics/javascript.html#Accessing_Collection_Items Accessing Collection Items COM objects can have properties that return a collection object. Some scripting languages like VBScript allow accessing collection items directly, for example, obj.Cells(i, j) rather than obj.Cells.Item(i, j). JavaScript does not support this. To access items of a collection object, you should specify the appropriate property (Item, Items) explicitly: JavaScript Log.Message(Excel.Cells.Item(i, j)); This discussion could be useful probably http://stackoverflow.com/questions/15763358/difference-between-htmlcollection-nodelists-and-arrays-of-objects1.6KViews1like0CommentsRe: Name Mapping - Extended Find - Changing parent URL
ThanksAll. I managed to do "Extended Find" , so I just skip the pageURL and I put all elements directly under Sys-Browser. I also tried to wildcard the URL , www.*.com. The problem with those solutions is TC tends to take much more time and the playback process becomes much much slower when I have heaps of open Chrome tabs. I think TC doesn't know in which tab does this web element sit and it needs to search in each and every tab. Sometimes it took 5 minutes just to find the boxand it returns Searching for the mapped object "WarningBox" took a long time. This happened because the sought-for object has the Extended Find attribute enabled, and the test engine searched for this object on all levels down the object hierarchy. To speed up the search and improve the test performance, add more parent objects of this object to the Mapped Objects tree of Name Mapping. Anyway, thanks for all the suggestions:smileyhappy:2.1KViews0likes0Comments