javascript - PhantomJS 我的代码甚至不会点击或运行点击

标签 javascript click phantomjs

我正在尝试运行单击功能SelectPlaystation4(从底部数第8个)。 PhantomJS 能做到这一点吗?我怎样才能在 phantomjs 中做到这一点?我一直在尝试使用文档中的评估...但没有任何运气

<div id="content" class="clearfix">        

    <section class="content" style="margin-bottom: 35px;">          

      <div id="col-main" class="clearfix">

<div class="col-md-12 console-ps">
    <div class="collection-details text-center">
      <h3>
        Playstation
      </h3>
      <div class="line"></div>
       <!--<a href="#" class="col-btn btn">PS3</a>-->
       <input type="button" class="col-btn btn" onclick="SelectPlaystation4()" value="Playstation 4">
       <input type="button" class="col-btn btn" onclick="SelectPlaystation3()" value="Playstation 3">

    </div>
</div>

<div class="col-md-12 console-xb">
    <div class="collection-details text-center">

最佳答案

onclick 函数不会创建点击,它只是一个点击处理程序,导致点击时发生其他事情。

对于您想要实现的目标,您需要查看 Phantomjs sendEvent。你可以找到那些docs here .

来自文档:

Mouse events

sendEvent(mouseEventType[, mouseX, mouseY, button='left'])

The first argument is the event type. Supported types are 'mouseup', 'mousedown', 'mousemove', 'doubleclick' and 'click'. The next two arguments are optional but represent the mouse position for the event.

The button parameter (defaults to left) specifies the button to push.

For 'mousemove', however, there is no button pressed (i.e. it is not dragging).

关于javascript - PhantomJS 我的代码甚至不会点击或运行点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38627169/

相关文章:

javascript - 关闭简单的精美框弹出并使用联系表 7 将成功消息显示为警报

javascript - 正则表达式仅使用第一个单词来匹配复合词

jquery - 可拖动元素运行单击功能

javascript - 无法让 jquery click 事件在 ajax 生成的 HTML 上工作

javascript - 在 PhantomJS 中使用 Jasmine 测试 $interval

javascript - 禁用在 IE 中有效,但在 Firefox 中无效

c++ - Qpushbutton点击并不总是有效

javascript回调闭包 undefined variable

java - 在java程序中执行phantomjs脚本

javascript - Meteor onCreateUser方法错误