2017-10-09 14 views
0

내 2e2 테스트 w Nightwatch.js에서 WebDriver 프로토콜을 사용하여 요소를 가져올 수 있지만 결과 (res.value)는 요소 ids 배열입니다.Vue.js e2e Nightwatch.js WebElements (WebDriver 프로토콜)에 대한 세부 정보를 얻는 방법은 무엇입니까?

어떻게 이러한 요소에 대한 세부 정보를 얻을 수 있습니까? ?

[ { ELEMENT: '0.03261545200301663-4' }, 
    { ELEMENT: '0.03261545200301663-5' } ] ' length: ' 2 
FIRST ELEMENT ID: 0.03261545200301663-4 
FIRST ELEMENT TAG NAME: undefined 

E2E/...

module.exports = { 

     'Add shoppinglist': (browser) => { 
     const devServer = browser.globals.devServerURL 
     // open the browser and wait for #app to be on the page 
     browser.url(devServer).waitForElementVisible('#app', 5000) 
     // check the title of the current active tab 
     browser.expect.element('ul.nav-tabs li.active a').text.to.equal('Groceries') 
     // click on add shopping list plus button 
     browser.click('#addShoppingListIcon') 

     // get shopping list tab title elements 
     browser.elements('css selector', 'ul.nav-tabs li', (res) => { 
      console.log(res.value, ' length: ', res.value.length) 
      console.log('FIRST ELEMENT ID: ', res.value[0].ELEMENT) 
      console.log('FIRST ELEMENT TAG NAME: ', res.value[0].tag_name) 
      console.log('FIRST ELEMENT CSS CLASS: ', res.value[0].style('class')) 
     }) 

     browser.pause(1000) 
     // check the title of the active tab 
     browser.expect.element('ul.nav-tabs li.active a').text.to.equal('New Shopping List') 
     // check the title of the active content panel 
     browser.expect.element('#app .tab-content .tab-pane.active h2').text.to.equal('New Shopping List') 
     // check the default value of the footer change title input field 
     browser.getValue('#app .tab-content .tab-pane.active .footer input.input[name=title]', (result) => { 
      browser.assert.equal(result.value, 'New Shopping List') 
     }) 
     browser.end() 
     } 
    } 

답변

0

후속 요청에 대해 ID로 ELEMENT를 사용해야 test.js

browser.elements('css selector', 'ul.nav-tabs li', (res) => { 
     console.log(res.value, ' length: ', res.value.length) 
     console.log('FIRST ELEMENT ID: ', res.value[0].ELEMENT) 
     browser.elementIdAttribute(res.value[0].ELEMENT, 'class', (value) => { 
     console.log('FIRST ELEMENT CLASS ATTRIBUTE: ', value) 
     }) 
    }) 

    console.log 
    FIRST ELEMENT CLASS ATTRIBUTE: { sessionId: '13a05b81a71d8860df5432fc7e585ab5', 
     status: 0, 
     value: 'active' }