Selenium click事件不会触发angularjs ng-click

man*_*utd 9 selenium selenium-ide angularjs selenium-webdriver

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

<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>
Run Code Online (Sandbox Code Playgroud)

有多个文本框和关联的保存按钮.根据'config-value'(您可以在顶部看到),值将被保存.

Shu*_*ain 7

根据您的方便更换定位器

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

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);
Run Code Online (Sandbox Code Playgroud)

要么

JavascriptLibrary jsLib = new JavascriptLibrary();
jsLib.callEmbeddedSelenium(driver,"triggerMouseEventAt", element,"click", "0,0");
Run Code Online (Sandbox Code Playgroud)

要么

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();
Run Code Online (Sandbox Code Playgroud)

希望它能帮到你:)

如果仍然面临问题,请回复我:)