Forum Discussion

pavithiras's avatar
pavithiras
Occasional Contributor
9 months ago

Data Driven Testing Dropdown

Is it possible to make a Data-driven Keyword test for a web page that contains four fields, Which includes two text box fields and two drop down fields. How can I make it data driven, and I am going to get the inputs from an Excel sheet.

Thanks.

20 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I don't know what your control looks like; it may look similar to a standard control, but the behaviour might be different. As you mentioned drop down, which implies a list of items in a drop down list, I had suggested to use ClickItem method.

     

    The Object Spy tool gives a list of methods that can be used against the control

     

    You need to understand the behaviour of your control, and use the appropriate methods to perform the actions you require.

    • pavithiras's avatar
      pavithiras
      Occasional Contributor

      Hi rraghvani,

       

      Thank you so much for helping me out, When I use the spy object to check the methods of my drop down, I find that it is not being recognised as a dropdown, that is why clickItem method is not showing up, but able to solve the issue. 

      Thank you.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Object Spy will usually indicate the type of the UI object, and the methods exposed by the object, which can be used to perform various actions on the UI object. It's worth learning the basics of TC.

    • pavithiras's avatar
      pavithiras
      Occasional Contributor

      I was trying to do that, It is working for the text boxes. But for the drop down it is not taking values from the excel.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Within your data driven loop, try to output the value to message log. To check if you are reading the correct values from your Excel spreadsheet.

    • pavithiras's avatar
      pavithiras
      Occasional Contributor

      Hi, Thank you for helping me out.
      I tried to check that values, it displays the expected value in log message. It clicks the drop down box and it's not able to find the data to match from the excel data. 
      EG: In excel it says January as the data, But after clicking the month dropdown it was not able to click on January. IS that because of click method?

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Try using for example ClickItem("January") method.

     

    I don't know what your control looks like, as not all controls are the same.

    • pavithiras's avatar
      pavithiras
      Occasional Contributor

      I am using a web application, this method says it cannot be used in Web app.
      My control looks like, For example: It looks like a calendar where it has a drop down for months and years and we need to select the months and year that we are getting from the excel.

       

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Try recording a little test to access the drop down and see what code TestComplete gives you for those actions.

    • pavithiras's avatar
      pavithiras
      Occasional Contributor

      Hi Marsha,

      I tried making a test which records just a single person data, for the drop down. It is creating an aliases (Name Mapping) and and it maps the month I selected during the recording and uses the click method to select the month when I run the test. 

      How can I send a variable for the click method?

      Thank you in advance.

    • pavithiras's avatar
      pavithiras
      Occasional Contributor

      Hi Marsha,

      I tried making a test which records just a single person data, for the drop down. It is creating an aliases (Name Mapping) and and it maps the month I selected during the recording and uses the click method to select the month when I run the test. 

      How can I send a variable for the click method?

      Thank you in advance.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    ClickItem method used on a website, to click item "Audi",

     

     

     

    • pavithiras's avatar
      pavithiras
      Occasional Contributor

      Hi,

      I tried the Eg that you sent, when I record that with keyword test or as a script it is getting recognized as drop down and it automatically creates clickitem. (Code:Aliases.chrome.pageW3schoolsTryitEditor.frameIframeresult.selectChooseACar.ClickItem(Project.Variables.car1.Value("Car")); ) and it is getting input from the excel and selects accordingly.

      But when I do the same in the page where I want to test it is creating a click function instead of clickitem function, I assume it is not getting recognized as a drop down. When I try to change that manually it says ClickItem("Date") not found.

       

  • pavithiras's avatar
    pavithiras
    Occasional Contributor

    Hi, 

    Thank you so much, Can you share the code that you used?

    If I type ClickItem in the operations panel to find it, it doesn't show any operation with that.

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    See the screenshots I have provided, one is written in JavaScript and the other is a Keyword Test.

     

    ClickItem is a method of ObjectType Button.