简体   繁体   English

使用Webdriver,如何单击具有数据绑定“ mousedown”事件的按钮?

[英]With Webdriver, how do I click a button that has a data-bind 'mousedown' event?

I am using WebdriverIO and WebdriverCSS to create a visual regression test suite. 我正在使用WebdriverIO和WebdriverCSS创建可视回归测试套件。

The page I am currently testing has a form with a submit button, however, when I send try to click on this button, the form is not submitted. 我当前正在测试的页面具有一个带有“提交”按钮的表单,但是,当我发送尝试单击此按钮的表单时,该表单未提交。

The HTML for the button is below 该按钮的HTML如下

<div class="submit_jump_patch" data-bind="event: {'mousedown': $root.formSubmitHandler }">
    <input type="submit" name="journey_save" value="Next" id="journey_save" class="btn btn_primary btn_large float_right full_width_m" data-bind="css : { 'spinner' : showSpinner, 'disabled' : disableSubmit }, attr: { 'aria-busy' : showSpinner() ? 'true' : 'false' }" aria-busy="false">
</div>

I have tried the following webdriverIO commands: .click .moveToObject.click() .execute ( 我已经尝试了以下webdriverIO命令:.click .moveToObject.click().execute(

Unfortunately I am unable to change the HTML so that it doesn't require the 'mousedown' event, and I am unsure why it is there in the first place. 不幸的是,我无法更改HTML,因此它不需要'mousedown'事件,而且我不确定为什么会首先出现它。

Try using selectorExecute 尝试使用选择器执行

browser.selectorExecute(".submit_jump_patch", function (submitDiv) {
            submitDiv[0].mousedown();
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM