错误:ReferenceError:找不到变量:Casperjs中的livePerson

时间:2018-08-07 04:20:49

标签: javascript phantomjs automated-tests casperjs

我正在尝试使用CasperJs和PhantomJs编写自动旅程测试:

我的Package.json如下:

Option Explicit
Public Sub GetInfo()
    Dim sResponse As String, i As Long, html As New HTMLDocument
    Application.ScreenUpdating = False
    With CreateObject("MSXML2.XMLHTTP")
        .Open "GET", "https://www.lenovo.com/sg/en/laptops/c/LAPTOPS", False
        .send
        sResponse = StrConv(.responseBody, vbUnicode)
    End With
    sResponse = Mid$(sResponse, InStr(1, sResponse, "<!DOCTYPE "))
    Dim info As Object, prices As Object, titles As Object
    With html
        .body.innerHTML = sResponse
        Set titles = .querySelectorAll(".facetedResults-title")
        Set info = .querySelectorAll(".expandableContent.facetedResults-expandableContent-features.expandableContent-is-collapsed.facetedResults-expandableContent-69")
        Set prices = .querySelectorAll(".expandableContent.facetedResults-expandableContent-price.expandableContent-is-collapsed")
    End With
    With Worksheets("Sheet1")
        For i = 0 To titles.Length - 1
            .Cells(i + 1, 1) = titles(i).innerText
            .Cells(i + 1, 2) = info(i).innerText
            .Cells(i + 1, 3) = prices(i).innerText
        Next i
    End With
    Application.ScreenUpdating = True
End Sub

我正在尝试使用以下命令执行测试:

{
  "name": "casperjsdemo",
  "version": "1.0.0",
  "description": "",
  "main": "JourneyTest.js",
  "scripts": {
    "test": "./node_modules/mocha-casperjs/bin/mocha-casperjs JourneyTest.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com"
  },
  "dependencies": {},
  "devDependencies": {
    "mocha-casperjs": "~0.3.2",
    "casperjs": "^1.1.3",
    "phantomjs": "^2.1.7"
  },
  "homepage": "https://github.com"
}

但是:(我正在关注错误:

node_modules/casperjs/bin/casperjs test <JourneyTestFile>.js

作为参考,我的旅程测试文件如下:

Error: ReferenceError: Can't find variable: livePerson

强文本

0 个答案:

没有答案