1e41f4b71Sopenharmony_ci# Test Subsystem ChangeLog
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## cl.testfwk_arkxtest.1 Exception Handling Support of On, Driver, and Component APIs
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciThe original APIs in API version 8 are deprecated, and substitute APIs that support exception handling are introduced in API version 9. You must use **try catch** to capture exceptions thrown by the APIs.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci## Change Impacts
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ciThis change affects the JS APIs in API version 9 provided by **@ohos.uitest**. If you have used the API of **@ohos.uitest-api9** during test case development, adaptation is required so that the compilation can be successful in the SDK environment of the new version.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## Key API/Component Changes
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci- The **By** class in API version 8 is deprecated and replaced by the **On** class in API version 9. The APIs of the **On** class support exception handling and retain their original name, with the exception of **By#key**, which is renamed **On.id**.
14e41f4b71Sopenharmony_ci- The **BY** object in API version 8 is deprecated and replaced by the **ON** object in API version 9.
15e41f4b71Sopenharmony_ci- The **UiDriver** class in API version 8 is deprecated and replaced by the **Driver** class in API version 9. The APIs of the **Driver** class support exception handling and retain their original name.
16e41f4b71Sopenharmony_ci- The **UiComponent** class in API version 8 is deprecated and replaced by the **Component** class in API version 9. The APIs of the **Component** class support exception handling and retain their original name.
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci## Adaptation Guide
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci1. Adapt to the API name changes.
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci   You can replace the class name according to the following rules:
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci   - `By-->On`
25e41f4b71Sopenharmony_ci   - `BY-->ON`
26e41f4b71Sopenharmony_ci   - `UiDriver-->Driver`
27e41f4b71Sopenharmony_ci   - `UiComponent-->Component`
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci2. Catch and handle exceptions.
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci   Use **try-catch** to catch and handle exceptions thrown by the APIs. Below is the sample code:
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci   ```typescript
34e41f4b71Sopenharmony_ci   import {Driver,ON,Component} from '@ohos.uitest'
35e41f4b71Sopenharmony_ci   
36e41f4b71Sopenharmony_ci   try {
37e41f4b71Sopenharmony_ci       let driver = Driver.create();
38e41f4b71Sopenharmony_ci   } catch (error) {
39e41f4b71Sopenharmony_ci       // error handle; error.code indicates the error code.
40e41f4b71Sopenharmony_ci   }
41e41f4b71Sopenharmony_ci   ```