diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/NavRouterPage.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/NavRouterPage.ets index bea53d01c707d1994f066d36cb2ff4f94855b117..82aaaed81dd1ea4305ce7db22088200ae4ce34aa 100644 --- a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/NavRouterPage.ets +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/NavRouterPage.ets @@ -70,7 +70,7 @@ struct NavRouterPage { Flex({ direction: FlexDirection.Row }) { Row() { Image($r('app.media.icon')).width(40).height(40).borderRadius(40).margin({ right: 15 }) - Text('Hello').fontSize(30).key('textContent' + (item + 1).toString()) + Text('Hello').fontSize(30).key('textContent') }.padding({ left: 15 }) } }.backgroundColor('#ccc') @@ -91,7 +91,7 @@ struct NavRouterPage { .hideTitleBar(true) .hideToolBar(true) .height('80%') - Text(this.stateChange).fontSize(20).margin(10).id('123') + Text(this.stateChange).fontSize(20).margin(10).key('testT') }.height('100%') } } diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/NavRouterJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/NavRouterJsunit.test.ets index 6f714bf3f64674a9d4afdbee3947c9f4534e5775..30cee3dc37e48b1904b39a0b4347ef2562b88b9f 100644 --- a/arkui/ace_ets_component_ui/entry/src/main/ets/test/NavRouterJsunit.test.ets +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/NavRouterJsunit.test.ets @@ -53,25 +53,14 @@ export default function NavRouterJsunit() { let navRouter2 = await driver.findComponent(BY.key('NavRouter2')); await navRouter2.click(); await CommonFunc.sleep(1000); - let stateChange = await driver.findComponent(BY.id(123)); - await stateChange.click(); - await CommonFunc.sleep(1000); + let stateChange = await driver.findComponent(BY.key('testT')); let text1 = await stateChange.getText(); console.info("[NavRouterJsunit_0100] text1: " + JSON.stringify(text1)); expect(text1 == 'stateChange true').assertTrue(); - - let textComponent = await driver.findComponent(BY.key('textContent1')); + let textComponent = await driver.findComponent(BY.key('textContent')); let text2 = await textComponent.getText(); console.info("[NavRouterJsunit_0100] text2: " + JSON.stringify(text2)); expect(text2 == 'Hello').assertTrue(); - - await CommonFunc.sleep(1000); - let stateChange3 = await driver.findComponent(BY.id(123)); - await stateChange3.click(); - await CommonFunc.sleep(1000); - let text3 = await stateChange.getText(); - console.info("[NavRouterJsunit_0100] text3: " + JSON.stringify(text3)); - expect(text3 == 'stateChange false').assertTrue(); console.info('[NavRouterJsunit_0100] END'); done(); });