Ask a Question

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

Nilam
Occasional Contributor

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 6
tristaanogre
Community Hero

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

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?


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Nilam
Occasional Contributor

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

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
Community Hero

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

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Nilam
Occasional Contributor

Re: 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"))
I used  page.Keys("[Enter]") after this but it is working only for one iteration , in 2nd iteration again it's failed to select an item from dropdown.

tristaanogre
Community Hero

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

Are you certain the value of "Reason" is actually in the drop down?  I've had situations in my own AUT where there is an extra space at the end of the item that wasn't immediately visible on screen.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
AlexKaras
Community Hero

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

Hi,

 

> page.NativeWebObject.Find

I would highly recommend not to use NativeWebObject but move to TestComplete's provided .FindChild() method:

page.FindChild(...)

 

> but it is working only for one iteration

I hope that https://community.smartbear.com/t5/TestComplete-General-Discussions/You-are-trying-to-call-the-quot-... explains the possible reason for this.

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: