尝试单击SVG元素时,单击在伪造者中不起作用

时间:2019-04-30 10:01:10

标签: reactjs jest-puppeteer

我是木偶游戏的新手。我正在尝试编写一个测试,其中用户单击编辑按钮,然后更改字段名称,然后根据需要单击“取消”(x图标)或“确定”(选中图标)。这两个按钮都作为SVG元素显示。

我尝试使用page.evaluate,page。$,page。$ eval单击svg元素,然后仅单击该元素。元素没有任何关联的ID,因此我使用“类”标签进行标识。

实际输出: 评估失败:TypeError:element.click不是函数

  at __puppeteer_evaluation_script__:2:32
  at ExecutionContext.evaluateHandle (node_modules/puppeteer/lib/ExecutionContext.js:121:13)
    -- ASYNC --
  at ExecutionContext.<anonymous> (node_modules/puppeteer/lib/helper.js:110:27)
  at ExecutionContext.evaluate (node_modules/puppeteer/lib/ExecutionContext.js:48:31)
  at ExecutionContext.<anonymous> (node_modules/puppeteer/lib/helper.js:111:23)
  at DOMWorld.evaluate (node_modules/puppeteer/lib/DOMWorld.js:105:20)
    -- ASYNC --
  at Frame.<anonymous> (node_modules/puppeteer/lib/helper.js:110:27)
  at Page.evaluate (node_modules/puppeteer/lib/Page.js:809:43)
  at Page.<anonymous> (node_modules/puppeteer/lib/helper.js:111:23)
  at evaluate (__tests__/test1.js:590:26)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:296:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
  at step (__tests__/test1.js:3:191)
  at __tests__/test1.js:3:361

0 个答案:

没有答案