Wednesday, October 02, 2013

sendKeys to combobox, textbox or datefield (Selenium Web Driver + JUnit + ExtJS)

In my previous post Locate ExtJS Component (Selenium Web Driver + JUnit + ExtJS), I introduced some code snippets to find an ExtJS component using ComponentQuery. However, the elements located using that approach generally do not accept user input (except mouse click seems to work for button). Turns out ExtJS render these components using a lot of HTML markups wrapping around the real input element. The inputEl is usually the HTML element that accepts user input. So to send keys to them, a slight change is needed from the code I published in the previous post. We will need to drill down 1 level to retrieve HTML id of inputEl, and get its DOM element:

4 comments:

Anonymous said...

Hi,Nice blog.

I have a question. IF a page has more than 1 inputbox how this script will identify the each input box uniquely?

Guogang Hu said...

The component query string must be constructed such that one and only one input will be selected. If it's not easy to guarantee that, then more error checking need to be added.

Kamlesh Shete said...

Hello Guogang Hu ...
Can u please provide full exple of component querry . please , can you provide some explaination and if any configuration is required for project SJTXE. and
can u please provide full project of locating the components.
Thanks

Guogang Hu said...

I created a github repo: https://github.com/huguogang/SJTXE. Please check it out.