硒单击事件不会触发angularjs事件 [英] Selenium click event does not trigger angularjs event

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

问题描述

我在此页面上有一个angularjs模态内容弹出窗口,在该页面中我填写了一些字段,然后单击保存".启动保存后,弹出窗口将消失,否则将发生事件.

I have this page where an angularjs modal-content popup, in there i fill up some fields and click save. After save is initiated, popup should dissapear an event should happen and so on.

我的硒测试可以完美地完成所有操作,除了单击保存按钮时,弹出窗口消失了,但是没有触发或保存任何事件,因此当我再次打开窗口时,所有内容都为空.我已经用硒尝试了一些我知道的东西,但是它仍然不起作用.有人可以帮我吗?

My selenium test does all that perfectly except that when it clicks on the save button, popup dissapears but no event is triggered or saved so when i open up the window again everything is empty. I've tried stuff that i know with selenium and it still doesn't work. Can anyone help me out here?

这是保存按钮:

<button class="save-button" data-ng-click="onSettingsSave()" ng-hide="readOnlyMode || !canSave()">Save</button>

我尝试过的东西:

var saveButton = driver.FindElement(By.CssSelector("button.save-button"));
saveButton.Click();

var saveButton = driver.FindElement(By.XPath(saveXpath));
saveButton.SendKeys(Keys.Enter);

((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].focus();",saveButton);
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click();",saveButton );

推荐答案

尝试使用纯JS强制单击元素:

Try force clicking the element using pure JS:

driver.execute_script("arguments [0] .click();",yourElement)

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆