0

Currently I'm working on TestComplete automation tool. I'm facing a problem in selecting a value from a dropdown using Jscript. It can done easily in javascript by

document.getElementById("id").options[1].selected=true

I cant do it using JScript'. I've tried

Browsers.Item(btIExplorer).Run("Page URL"); //opening the browser and running a URL
    browser=Aliases.browser; //creating alias of browser object
    page=browser.Page("PageURL"); //creating a page object for the page opened
   page.NativeWebObject.Find("id", "defaultLocationBinder_newOrExisting", "input") // This is the dropdown

I'm not able to find any suitable option to select the options in the dropdown which are given in the <option></option> tags

2 Answers 2

3

I just wrote this piece of code and was able to do it. Use the selectedIndex to set the option you want.

use the object spy to check the properties/methods you can use with the object.

function loginDropDown()
    {
      var dropDown = Sys.Browser("iexplore").Page("*").FindChild("Name","Select(\"myList\")",10,true)
      dropDown.selectedIndex = 1

    }
Sign up to request clarification or add additional context in comments.

Comments

0

The NativeWebObject.Find method returns a native object while you may want to work with a TestComplete wrapper. Use the Find or FindChild method to get such a wrapper and the Clickitem method to select a specific item.

function test()
{
  var b = Sys.Browser("iexplore");
  b.ToUrl("http://support.smartbear.com/message/?prod=TestComplete");
  var page = b.Page("http://support.smartbear.com/message/?prod=TestComplete");
  var cBox = page.FindChild("ObjectIdentifier", "ddlRequestType", 20);
  cBox.ClickItem("General product question");
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.