Custom Attributes on controls

0
1

Hi, is it possible to have custom attributes on controls that appear in the dom, we use them in our automation tests in order to identify controls.

  • You must to post comments
0
0

Hi Peter,

Wisej.NET already has a built-in feature to make it easier to identify elements for automation tests.

It’s as easy as setting up the default.json file by adding the following:


"options": {
"automation.mode": true
}

 

The complete JSON would be as follows:

{
"url": "Default.html",
"startup": "Wisej_Project_Name.Program.Main, Wisej_Project_Name",
"options": {
"automation.mode": true
}
}

Basically, what this feature does is that it replaces all the obfuscated ids of the controls and gives you a hierarchical representation of the control so you can easily identify all the components.

As an example, you can have a Button inside of a FlowLayoutPanel, instead of that button being represented as “id_X” in the dom, it would be something like: Page1_flowLayoutPanel1_Button.

HTH,
Alaa

  • Peter Stone
    The problem is that all our forms are dynamic and all fields are related to id so if we move a field order we can pick it up with our software but if the path has changed then it will find it in the wrong place if we use Id_X for instance.
  • Alaa (ITG)
    Yes, I understand that, that’s why with the automation mode you’ll have a static id for all the controls, even if the order changes.
  • Alaa (ITG)
    Also, all Wisej controls are JavaScript components, meaning if you want to add custom attributes for all the controls you’ll have to write a custom InitScript for any control that you have, and if you’re creating these controls in code it can be a mess at some point. I would always recommend that you use the automation.mode!
  • Alaa (ITG)
    Peter, a second option would be to use the name attribute, it can be set in code either by using the Name or AccessibleName property.
  • Peter Stone
    I will use the name attribute, I did see that but thought there might of been a way to be able to add an additional attribute.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.