Forum Discussion

Nilam's avatar
Nilam
Occasional Contributor
7 years ago

Unable to select an item from a combo box on Firefox by using Keys, ClickItem, SelectItem.

  page.NativeWebObject.Find("id", "step2_purposeOfTxn", "select").Keys(Project.Variables.MAT_Inputs("Reason"))

6 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    So... I see a problem... and a line of code... but what exactly happens?  Are you getting an error message? If so, what error?  What behavior is going on?

     

    My best guest....  ... You're getting an error something on the lines of that it cannot execute the Keys method of a null object or something to that effect.  You are "finding" a component...  but you're not verifying that the component is actually found before you interact.  No matter what browser you are using, that's the best practice in such situations.

     

    Now, I'm asssuming, based upon the title, that the code you posted works fine on some other browser...  and that's entirely likely.  Different browsers render stuff differently.  Some properties, id's, etc, in the rendered HTML are different between Chrome, IE, Firefox, Safari, etc.  This is why while the NativeWebObject.Find works pretty well, it has a bit of danger in it where you might be trying to find an object by a property that is rendered differently in a different browser.  So, that said, when  you use the ObjectSpy to look for the object in FireFox, how does it display?  What properties are displayed?

     

    Also... what version of TC are you using?  Firefox recently had a pretty significant update... and with that update, you may need to do a bit of patching on TC.  Have you tried the Help | Check for updates to see if a firefox update is available for your version of TC?

    • Nilam's avatar
      Nilam
      Occasional Contributor

      1)It's a required field in UI and In Firefox it is printing the value in test log but not exactly select that item contain by "Reason". That combo box doesn't contain any value after putting (Project.Variables.MAT_Inputs("Reason")) from sheet.
      A
      part from this it's going to the next page successfully.


      2) Currently i am working on Test Complete 11.20.1491 but this is not right time for us to update it and browsers(firefox) too.

      3) how can object spy help me to solve this problem 

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Object Spy will display to you within TestComplete how TestComplete identifies the object.  Again, as noted in my post, this was a guess as to what's going on due to your lack of detail.  However, since object identification doesn't seem to be the problem, this is moot.

         

        However... here's my thinking...  the combobox field you're sending the keys command to might have an "on-exit" event that, if the keystrokes aren't entered properly, might fail to actually complete the process.  Sometimes this is handled simply by adding the "Enter" keystroke.

         

        Try changing your code to :


         

        var myObject = page.NativeWebObject.Find("id", "step2_purposeOfTxn", "select")
        if (myObject.Exists){
            myObject.Keys(Project.Variables.MAT_Inputs("Reason")+'[Enter]')
        }

        Two things... first, before attempting to work with the object, I check to make sure that I actually found something.  This is ALWAYS a best practice when using a Find method.  Secondly, this will add the enter keystroke at the end of the data entry to trigger any "on-exit" or other events that might be necessary to complete the data entry field.  Give this a try and see if it works.