1# @ohos.app.ability.abilityDelegatorRegistry (AbilityDelegatorRegistry) 2 3**AbilityDelegatorRegistry**, a module of the [Test Framework](../../application-test/arkxtest-guidelines.md), is used to obtain [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) and [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) objects. **AbilityDelegator** provides APIs for creating **AbilityMonitor** objects, which can be used to listen for ability lifecycle changes. **AbilityDelegatorArgs** provides APIs for obtaining test parameters. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> The APIs provided by this module can be used only in the test framework. 9 10## Modules to Import 11 12```ts 13import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; 14``` 15 16## AbilityLifecycleState 17 18Enumerates the ability lifecycle states. It can be used in [getAbilityState(ability)](js-apis-inner-application-abilityDelegator.md#getabilitystate9) of [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) to return different ability lifecycle states. 19 20**System capability**: SystemCapability.Ability.AbilityRuntime.Core 21 22| Name | Value | Description | 23| ------------- | ---- | --------------------------- | 24| UNINITIALIZED | 0 | The ability is in an invalid state. | 25| CREATE | 1 | The ability is created.| 26| FOREGROUND | 2 | The ability is running in the foreground. | 27| BACKGROUND | 3 | The ability is running in the background. | 28| DESTROY | 4 | The ability is destroyed.| 29 30## AbilityDelegatorRegistry.getAbilityDelegator 31 32getAbilityDelegator(): AbilityDelegator 33 34Obtains an [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) object. 35 36**System capability**: SystemCapability.Ability.AbilityRuntime.Core 37 38**Return value** 39 40| Type | Description | 41| ------------------------------------------------------------ | ------------------------------------------------------------ | 42| [AbilityDelegator](js-apis-inner-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-inner-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule the functionalities of the test framework.| 43 44**Example** 45 46```ts 47let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); 48 49let want = { 50 bundleName: 'com.ohos.example', 51 abilityName: 'MainAbility' 52}; 53abilityDelegator.startAbility(want, (err) => { 54 if (err.code !== 0) { 55 console.log('Success start ability.'); 56 } else { 57 console.log('Failed start ability, error: ' + JSON.stringify(err)); 58 } 59}) 60``` 61 62## AbilityDelegatorRegistry.getArguments 63 64getArguments(): AbilityDelegatorArgs 65 66Obtains an [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) object. 67 68**System capability**: SystemCapability.Ability.AbilityRuntime.Core 69 70**Return value** 71 72| Type | Description | 73| ------------------------------------------------------------ | ------------------------------------------------------------ | 74| [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) | [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) object, which can be used to obtain test parameters.| 75 76**Example** 77 78```ts 79let args = AbilityDelegatorRegistry.getArguments(); 80console.info('getArguments bundleName:' + args.bundleName); 81console.info('getArguments parameters:' + JSON.stringify(args.parameters)); 82console.info('getArguments testCaseNames:' + args.testCaseNames); 83console.info('getArguments testRunnerClassName:' + args.testRunnerClassName); 84``` 85