未验证 提交 72b2d7eb 编写于 作者: O openharmony_ci 提交者: Gitee

!14963 更新使用文档

Merge pull request !14963 from 刘乐/monthly_20221018
......@@ -108,7 +108,7 @@ UI测试脚本是在单元测试框架的基础上编写,主要就是增加了
下面的示例代码是在上面的测试脚本基础上增量编写,首先需要增加依赖导包,如下示例代码所示:
```js
import {UiDriver,BY,UiComponent,MatchPattern} from '@ohos.uitest'
import {Driver,ON,Component,MatchPattern} from '@ohos.uitest'
```
然后是具体测试代码编写,场景较为简单,就是在启动的应用页面上进行点击操作,然后增加检查点检查用例。
......@@ -131,16 +131,16 @@ export default function abilityTest() {
expect(Ability.context.abilityInfo.name).assertEqual('MainAbility');
})
//ui test code
//init uidriver
var driver = await UiDriver.create();
//init driver
var driver = await Driver.create();
await driver.delayMs(1000);
//find button by text 'Next'
var button = await driver.findComponent(BY.text('Next'));
var button = await driver.findComponent(ON.text('Next'));
//click button
await button.click();
await driver.delayMs(1000);
//check text
await driver.assertComponentExist(BY.text('after click'));
await driver.assertComponentExist(ON.text('after click'));
await driver.pressBack();
done();
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册