Ask a Question

Event handler for textbox

SOLVED
aa1
Contributor

Event handler for textbox

Hi,

 

I have a situation where I have an amount text box and then Pay now button beneath it. When I enter the amount, the pay now button should be enabled and then the next step is to click on it. This is an automated script in Jscript. When I do manually, as soon as I enter the text, the pay button does get enabled. But when my automated script runs, it does settext in the textbox but then the button is still disabled. So the next event of clicking on it fails with the exception that the button is disabled. I tried to enable it but seems like I need to have an event handler for this. Do I write the event handler when the textbox has been filled in. Or may be in tab out from that textbox. Please help me to find the right approach.

 

thanks

8 REPLIES 8
Marsha_R
Champion Level 2

Try using Keys instead of SetText.  That mimics a user typing in the box instead of just updating the field.  Perhaps that will trigger your button.

Thank you for the reply. Yes I tried that but it made no difference at all. 

Marsha_R
Champion Level 2

What else have you tried and what exactly happened when you did?   It's hard to help if we have to guess at the details.

            Aliases.browser.page.form.textboxCreditCardNumber.Keys("");
            Aliases.browser.page.form.textboxCreditCardNumber.Keys("4110044510001234[Enter]");
            Aliases.browser.page.panel.panel.textboxCreditCardExpirationDate.Keys("");
            Aliases.browser.page.panel.panel.textboxCreditCardExpirationDate.Keys("12[Enter]");
            Aliases.browser.page.panel.panel.textboxExpirydateyear.Keys("");
            Aliases.browser.page.panel.panel.textboxExpirydateyear.Keys("2022");
            Aliases.browser.page.form.textboxCvvNumber.Keys("");            
            Aliases.browser.page.form.textboxCvvNumber.Keys("123");  
            Aliases.browser.page.form.textboxCvvNumber.Keys("[Enter]");           
            Aliases.browser.page.panel.panel.textboxExpirydateyear.Keys("[Tab]");
            Aliases.browser.page.panel.panel.textboxExpirydateyear.Keys("2022");
            Aliases.browser.page.panel.panel.textboxExpirydateyear.Keys("[Enter]");              
           
            aqUtils.Delay(ProjectSuite.Variables.ExistsTimeout);
            Runner.Pause();
            
            var btnPayNow = Aliases.browser.page.panel.panel2.buttonPayNow;            
           
            while (! btnPayNow.Exists)
            {
              aqUtils.Delay(ProjectSuite.Variables.ExistsTimeout);
              btnPayNow = page.NativeWebObject.Find("class", "Pay now", "btn btn-primary");
            }          
            
            
            btnPayNow.Click(); 

The above code is what I tried. I tried SetText as well. When it comes to the last line, it fails saying the button is disabled.

Marsha_R
Champion Level 2

Try doing a small recording of the manual entry and see what TestComplete gives you back.  

Wamboo
Community Hero

In my opinion, the button activates a different action than typing text into it.

 

Remember that in JavaScript use browser API you can specify many of the locations you want to activate (become available) for other elements on the page.

 

The text input action can't necessarily be the correct one.

 

Ask the developer what is responsible for activating the button.


Is it not a case of a click on a text field or a .focus or .hover, a tab.

 

In development tools such as Google chrome, you can perform such actions yourself by selecting an item and right-clicking on it,

sonya_m
SmartBear Alumni (Retired)

Community, thanks for your input.

@aa1 were you able to resolve this? 


Sonya Mihaljova
Community and Education Specialist

sonya_m
SmartBear Alumni (Retired)

@aa1 , I see you are working on this with the Support Team. Currently, they are waiting for more info from you.

Please provide them with the info so that they could move the investigation forward.

We will highly appreciate if you share the result of the investigation hereSmiley Happy Thank you.


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: