【问题标题】:Is it possible to execute a function that is written from the javascript of a website with nightmare? Or any other way?是否可以执行从噩梦网站的 javascript 编写的函数?还是有其他方式?
【发布时间】:2017-02-09 00:28:33
【问题描述】:

您知道当您访问网站中的页面并查看源代码时,有时您会看到某个元素执行 javascript 函数吗?例如:

<button type="button" id="chocolate" onclick="EditShipment()">Click me</button>

我可以使用 nightmare 访问这个页面并执行 EditShipment() 吗?如果是这样,是否可以将我们自己的参数传递给该函数的参数?

【问题讨论】:

  • 你应该按照以下方式做一些事情: document.getElementById('#chocolate").onclick = function() { EditShipment('arg'); } 然后使用 .click()跨度>

标签: javascript nightmare


【解决方案1】:

使用控制台并键入将在不单击按钮的情况下执行的函数名称

【讨论】:

  • 这不一样,因为this 值会有所不同。 EditShipment 函数可能取决于 this 是否正确设置。
猜你喜欢
  • 2021-09-23
  • 1970-01-01
  • 2014-04-29
  • 2014-07-29
  • 1970-01-01
  • 2011-03-17
  • 2015-07-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多