Ask a Question

Enum of possible options for TestComplete Element not showing up in Autocomplete / Code Completion

SOLVED
bjhiltbrand
Occasional Contributor

Enum of possible options for TestComplete Element not showing up in Autocomplete / Code Completion

I have a question,

 

I have a small script used to select values for different controls on a webpage. Because these values are finite, they are a perfect candidate for an Enum, so as to reduce the possibility of someone having a typo in text, and also to properly reference values in case they need to change in the future. Please see what I have below:

 

const assuranceLevel = Object.freeze({
  LOW: {value: 1, name: ' Low '},
  MODERATE: {value: 2, name: ' Moderate '},
  HIGH: {value: 3, name: ' High '},
  VERY_HIGH: {value: 4, name: ' Very High '}
});

function locateButtonGroup (buttonGroupTitleString) {
  return page.FindChildByXPath("//h4[text()='" + buttonGroupTitleString + "']/parent::div");
}

function selectLevel(buttonGroupElement, assuranceLevel) {
  buttonGroupElement.FindChildByXPath("./descendant::label[contains(text(), '" + assuranceLevel.name + "')]").Click();
}

function testPage() {
  selectLevel(locateButtonGroup("Overall SAL"), assuranceLevel.VERY_HIGH);
  selectLevel(locateButtonGroup("Confidentiality"), assuranceLevel.MODERATE);
  selectLevel(locateButtonGroup("Integrity"), assuranceLevel.VERY_HIGH);
  selectLevel(locateButtonGroup("Availability"), assuranceLevel.MODERATE);
}

 

 

This works as expected, and I can use one of the "assuranceLevel" options to constrain my choices to valid inputs. However, when typing assuranceLevel, when I hit the ".", I would expect an autocomplete window to come up, allowing me to select one of the viable options. That does not happen, and I have to type out the option. This defeats the entire purpose of using the enum in the first place, as the possibilities for typos still exist. It's frustrating that VSCode and sublime text editor can do this just fine, but TestComplete can't.

 

Is there any way to get TestComplete to display options from enums in autocomplete?

7 REPLIES 7
BenoitB
Community Hero

Start typing the option value, character per character till to the minimum length needed to raise the autocomplete list.
It's the way i do

Un sourire et ça repart

bjhiltbrand
Occasional Contributor

I have done that, as well as pressing ctrl+space to force the autocomplete window to come up. Nothing happens either way. Am I missing something?

did you put a wait in typing with the '[Pxxx]' syntax ?

 

Sounds strange, do you have access to dev team ? if yes please ask them how they've implemented the autocomplete, perhaps it's not a standard way.

 

The code below just check if autocomplete has occured and filled correctly the field (TextInput) with the wanted value (Value).

I've put a click on the field each characted typed, this is the only trick used.

 

          let i = 0;
          while ((!(TextInput.WaitProperty(PropertyName, Value, 100))) && (i<10)) {
            TextInput.Click();
            if (ClearField)
              TextInput.Keys('^a[Del]');
            let tableau = Value.split("");
            for (let j = 0; j<tableau.length; j++) {
              TextInput.Click();
              TextInput.Keys(tableau[j] + '[P250]');
              if (TextInput.WaitProperty(PropertyName, Value, 100))
                break;
            }
            i++;
          }

 

Un sourire et ça repart

bjhiltbrand
Occasional Contributor

No, I'm not talking about having autocomplete happen on the application under test. I'm talking about autocomplete in TestComplete itself when writing the script using javascript.

Lol .. did not understand that !

Sorry...

 

For code completion in TC, if even ctrl+space doesn't work on trivial case, need perhaps to contact Support.

 

Have you activated the code completion auto pop-up settings ? In tools -> options -> Panels -> Code editor -> Editing 

 

 

For your completion it will not work in this case unlesss you add your constants in an extension language package.

Un sourire et ça repart

Not supported but you can vote for them to be implemented

 

https://community.smartbear.com/t5/TestComplete-Desktop-Testing/Boost-TestComplete-code-autoCompleti...

 

Someone has a workaround (last message of the post)

https://community.smartbear.com/t5/TestComplete-Desktop-Testing/code-completion-for-user-defined-obj...

 

Un sourire et ça repart

bjhiltbrand
Occasional Contributor

Not the solution I was hoping for, but it gives me places to watch for implementation of this feature. Thanks. 🙂

cancel
Showing results for 
Search instead for 
Did you mean: