diff --git a/pages/API/element-get-attribute/element-get-attribute.test.js b/pages/API/element-get-attribute/element-get-attribute.test.js index ef8504f3be5d186ce435388c680c3d5f3e01ff99..a98e0552fd40e46e5306dde0bf3da94ca306b6dc 100644 --- a/pages/API/element-get-attribute/element-get-attribute.test.js +++ b/pages/API/element-get-attribute/element-get-attribute.test.js @@ -1,12 +1,7 @@ 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 - } +describe('test element-get-attribute', () => { + let page,platform,attrStyle,propertyValue; + platform = process.env.UNI_PLATFORM beforeAll(async () => { page = await program.reLaunch('/pages/API/element-get-attribute/element-get-attribute') await page.waitFor(3000); @@ -17,13 +12,23 @@ describe('/pages/API/element-get-attribute/element-get-attribute', () => { }); it('check setStyle getAttributeStyle', async () => { await page.callMethod('setStyle') - await page.callMethod('getAttributeStyle') - expect(await page.data('attrStyle')).toEqual('background-color:#FFF000'); + if(platform != 'app-plus'){ + await page.callMethod('getAttributeStyle') + attrStyle = platform == 'mp-weixin'?'background-color:#FFF000;':'padding: 0.625rem; background-color: rgb(255, 240, 0);' + expect(await page.data('attrStyle')).toEqual(attrStyle); + } }); - 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); + it('check getPropertyValue', async () => { + await page.callMethod('getPropertyValue') + propertyValue = platform == 'h5'?'rgb(255, 240, 0)':'#FFF000' + expect(await page.data('propertyValue')).toEqual(propertyValue); }); + if(platform != 'h5'){ + 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 index f623659e97079b628d2eccfa92f57315bc99cbb0..fb732e0a17d9e8e99d6d26ca23fbed68c35f649f 100644 --- a/pages/API/element-get-attribute/element-get-attribute.uvue +++ b/pages/API/element-get-attribute/element-get-attribute.uvue @@ -2,28 +2,38 @@ 元素的id:{{ attrId }} + 元素的style:{{ attrStyle }} + + 元素的背景色样式值:{{ propertyValue }} 小程序端:getAttribute 获取元素的属性值,目前仅支持id、style + App端:getAttribute 不支持获取 class、style 属性 + + + A B C + + -