Selenium 点击事件不会触发angularjs ng-click [英] Selenium click event does not trigger angularjs ng-click

查看:32
本文介绍了Selenium 点击事件不会触发angularjs ng-click的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个页面,其中有一个文本框,并且每个文本框都有关联的保存按钮.我需要单击保存按钮,以便将值保存在文本框中.它正在手动工作并使用硒.但是当通过 Selenium WebDriver 运行时,它不会保存文本框值.但是没有抛出错误异常.输入,点击工作.savetextvalue() 不会被触发.有类似的问题 Selenium 点击事件不会触发 angularjs 事件

<div class="div-mtl-tb-holder"><input type="text" placeholder="" class="tb-mtl" name="txtkbaemailauthsub" id="txtkbaemailauthsub"><button ng-click="saveTextValue();"ng-hide="false" class="btn btn-default btn-mtl btn-mtl-alignment" name="btnkbaemailauthsub" id="btnkbaemailauthsub" type="button">save</button>

</pp-save-control>

有多个文本框和关联的保存按钮.根据配置值"(您可以在顶部看到)值被保存.

解决方案

根据您的方便更换定位器

WebElement element= driver.findElement(By.id("btnkbaemailauthsub"));JavascriptExecutor executor = (JavascriptExecutor) 驱动程序;executor.executeScript("arguments[0].click();", element);

JavascriptLibrary jsLib = new JavascriptLibrary();jsLib.callEmbeddedSelenium(driver,"triggerMouseEventAt", element,"click", "0,0");

WebElement element= driver.findElement(By.id("btnkbaemailauthsub"));//配置动作动作动作=新动作(驱动程序);//聚焦元素action.moveToElement(element).perform();//点击元素action.moveToElement(element).click().perform();

希望对你有帮助:)

如果仍然遇到问题,请回复我:)

I have this page where there is a textbox and there is save button associated with each text box. I need to click on the save button so that it will save the value in text box. It is working manually and using selenium. But when running through Selenium WebDriver it's not saving the text box value. But there is no error exception being thrown. Input, Click is working. savetextvalue() is not triggered in short. There is similar issue Selenium click event does not trigger angularjs event

<pp-save-control fn-save-text="saveText();" btn-class="btn btn-default btn-mtl" button-id="btnkbaemailauthsub" place-holder-text="" input-class="tb-mtl" input-id="txtkbaemailauthsub" config-name="40" title-text="KBA email authentication subject" outer-container-class="div-mtl-header" class="ng-isolate-scope"><div class="div-mtl-header">
    <span class="label-mtl ng-binding">KBA email authentication subject</span><img ng-hide="(isHelpHidden != null &amp;&amp; isHelpHidden != 'true') ? false : true" class="help-mtl ng-hide" src="/Images/help.png">
    <div class="div-mtl-tb-holder">
        <input type="text" placeholder="" class="tb-mtl" name="txtkbaemailauthsub" id="txtkbaemailauthsub">
        <button ng-click="saveTextValue();" ng-hide="false" class="btn btn-default btn-mtl btn-mtl-alignment" name="btnkbaemailauthsub" id="btnkbaemailauthsub" type="button">save</button>
    </div>
</div>
</pp-save-control>

There are multiple text box and associated save button. Depending on the 'config-value'(You can see at top) value is getting saved.

解决方案

Replace the locator according to your convenience

WebElement element= driver.findElement(By.id("btnkbaemailauthsub"));

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);

OR

JavascriptLibrary jsLib = new JavascriptLibrary();
jsLib.callEmbeddedSelenium(driver,"triggerMouseEventAt", element,"click", "0,0");

OR

WebElement element= driver.findElement(By.id("btnkbaemailauthsub"));
// Configure the Action
Actions action = new Actions(driver);

//Focus to element
action.moveToElement(element).perform();

// To click on the element
action.moveToElement(element).click().perform();

Hope it will help you :)

Get back to me if still facing issue :)

这篇关于Selenium 点击事件不会触发angularjs ng-click的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆