1

我正在尝试使用:

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

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

 ✖ ReferenceError: document is not defined
4

1 回答 1

2

只需将其包装在执行中即可。这允许您操作任意的javascript。

.execute( function() {  
    var newGroups = document.getElementsByTagName("a.group-link")
    var id = newGroups[0].getAttribute('id')
    .click(id)
})
于 2018-08-24T21:47:37.093 回答