Ask a Question

Button detected as disabled during test run and causing test failure

AlexKaras
Community Hero

Re: Button detected as disabled during test run and causing test failure

Hi,

 

Thank you for the screenshot.

Try to replace SetText with Keys method in the operation that types 'Task1' (operation right above the green rectangle) and see if it helps.
If it does not, try to add one more operation that will move focus out of the AddTask_name field. (This can be done, for example, by calling the Focus() or SetFocus method for the AddTask_AddButton, depending on what method is supported by this given button).

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
================================
ThomasCasserly
Contributor

Re: Button detected as disabled during test run and causing test failure

I'll give those a try and hopefully one will work.

 

Thanks Alex

ThomasCasserly
Contributor

Re: Button detected as disabled during test run and causing test failure

Hi.


I have tried using the "Keys" method for entering the text t but I still get the button disabled error on the click method for the button.

 

I also found 2 focus methods available:

 

the first was "Focus" which had no parameters/values required, so I just set this for the Add button but got the same failure message that the Add button is disabled when the click operation is performed

 

The second method I tried was "AutoFocus" for which I set a boolean parameter of True for the Add button I am trying to click, again I got the button is disabled error message.

 

I have been talking to our developer here and he suggested that it may be a syntax recognition problem with how TestComplete is interpreting the HTML disabling of the button. I have pasted in the OUterHTML for the add button below. 1 shows HTML when the button is disabled, 2 when the button has been enabled. Could TestComplete have some issue in recognising the change from disabled to enabled??

 

1. <button type="button" id="dlgDLG_FRMWRK_002CreateObject" class="rf-button ui-button ui-corner-all ui-widget rf-dialog-submit ui-button-disabled ui-state-disabled" title="" disabled="">Add</button>

 

2. <button type="button" id="dlgDLG_FRMWRK_002CreateObject" class="rf-button ui-button ui-corner-all ui-widget rf-dialog-submit" title="">Add</button>

baxatob
Community Hero

Re: Button detected as disabled during test run and causing test failure

Hi,

 

Try to change NameMapping for this button using conditional mapping like:

 

outerHTML -> Does not equals -> *ui-state-disabled*

contentText -> Equals -> Add

ThomasCasserly
Contributor

Re: Button detected as disabled during test run and causing test failure

Hi, I tried adding conditions to the namemapping of the button and still getting the same result, error message that the button is disabled.

AlexKaras
Community Hero

Re: Button detected as disabled during test run and causing test failure

Hi,

 

> how TestComplete is interpreting the HTML

HTML markup has only one attribute (named 'disabled', https://www.w3schools.com/tags/tag_button.asp) that makes native HTML button to be enabled or disabled.

 

All other fancy dances with classes (class="ui-button-disabled...) are specific to this or that jscript library and are interpreted exclusively according to the implementation of the library. For example, nothing prevents library to define a class named ui-button-disabled and make a browser to display the UI element with this class applied as, say, enabled option button with some background image.

 

The core of your problem is that the state of the button is controlled by some jscript that analyses the state of the field (at least) and enables the button when the field contains some data and disables the button when the field is empty. Usually, such scripts are triggered by the events like keypresses or when control loses focus. Note, that script can be bound to the events that are triggered in response to explicit user's actions. For example, the event may be triggered in response to keypress, but be not triggered when the value of the field changes. This was the reason why I suggested to replace .SetText() method with the .Keys() one.


One more idea that you may try is to execute .Keys("[Tab]") after entering the value into the field. This will emulate as if the user pressed Tab key to move input focus to some other UI control from the current input field.

Also, you may try to execute .Keys("[Enter]") to emulate Enter press after data entry. This also may update some internal field's structures and trigger a change event. However, this also may trigger some default action. Tab is more safe in this sense, but you may try.

 

If nothing from above helps, I think that you should talk with developers and ask them what triggers the script that controls the state of the button and what end-user must do to trigger this event. Then you will emulate user's actions using .Keys() method.

 

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

Re: Button detected as disabled during test run and causing test failure

As workaround.

 

Try to run some JavaScript code to set disable property = false before you proceed to send keys.

 

 

https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/javascript.html

cancel
Showing results for 
Search instead for 
Did you mean: