在 nightwatch.js 中使用文档

using document in nightwatch.js

我正在尝试使用:

      var newGroups = document.getElementsByTagName("a.group-link")
      var id = newGroups[0].getAttribute('id')
      .click(id)

在 nightwatch.js 中 - 但每当我尝试使用“document”时,我都会收到以下错误:

 ✖ ReferenceError: document is not defined

只需将其包装在执行中即可。这样就可以任意操作javascript.

.execute( function() {  
    var newGroups = document.getElementsByTagName("a.group-link")
    var id = newGroups[0].getAttribute('id')
    .click(id)
})