From af617ea47b2816ed7911d7cfb9c0f8a9c4b5f212 Mon Sep 17 00:00:00 2001 From: anne-xml Date: Mon, 9 Dec 2024 16:25:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eelement-get-attribute?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 11 ++- .../element-get-attribute.test.js | 29 ++++++++ .../element-get-attribute.uvue | 67 +++++++++++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 pages/API/element-get-attribute/element-get-attribute.test.js create mode 100644 pages/API/element-get-attribute/element-get-attribute.uvue diff --git a/pages.json b/pages.json index 7a0eee0a..b3537cb7 100644 --- a/pages.json +++ b/pages.json @@ -1219,6 +1219,15 @@ } }, // #endif + // #ifdef MP-WEIXIN + { + "path" : "pages/API/element-get-attribute/element-get-attribute", + "style" : + { + "navigationBarTitleText" : "getAttribute | 获取元素的属性值" + } + }, + // #endif // #ifdef APP-ANDROID || APP-IOS { "path": "pages/API/facial-recognition-meta-info/facial-recognition-meta-info", @@ -3391,4 +3400,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/pages/API/element-get-attribute/element-get-attribute.test.js b/pages/API/element-get-attribute/element-get-attribute.test.js new file mode 100644 index 00000000..ef8504f3 --- /dev/null +++ b/pages/API/element-get-attribute/element-get-attribute.test.js @@ -0,0 +1,29 @@ +jest.setTimeout(30000); +describe('/pages/API/element-get-attribute/element-get-attribute', () => { + let page; + if (!process.env.uniTestPlatformInfo.startsWith('mp')) { + it('skip', () => { + expect(1).toBe(1) + }) + return + } + beforeAll(async () => { + page = await program.reLaunch('/pages/API/element-get-attribute/element-get-attribute') + await page.waitFor(3000); + }); + it('check getAttributeId', async () => { + await page.callMethod('getAttributeId') + expect(await page.data('attrId')).toEqual('box'); + }); + it('check setStyle getAttributeStyle', async () => { + await page.callMethod('setStyle') + await page.callMethod('getAttributeStyle') + expect(await page.data('attrStyle')).toEqual('background-color:#FFF000'); + }); + it('check scrollTo', async () => { + await page.callMethod('scrollTo') + await page.waitFor(100); + const scrollView = await page.$('.scroll-view_H') + expect(await scrollView.property('scrollLeft')).toBe(200); + }); +}); diff --git a/pages/API/element-get-attribute/element-get-attribute.uvue b/pages/API/element-get-attribute/element-get-attribute.uvue new file mode 100644 index 00000000..f623659e --- /dev/null +++ b/pages/API/element-get-attribute/element-get-attribute.uvue @@ -0,0 +1,67 @@ + + + -- GitLab