简体   繁体   English

如何在C#中执行Submit按钮的Js

[英]How to execute the Js of an Submit button in C#

Atm I am programming with Phantomjs and I noticed that some elements of js won't work because of the render process of Phantomjs, the same for Selenium chrome driver with the headless option on. Atm我正在使用Phantomjs进行编程,我注意到js的某些元素由于Phantomjs的渲染过程而无法使用,对于启用了无头选项的Selenium chrome驱动程序来说,这也是一样的。 The problem is button that have a render processes attached to them won't execute the js of the button when clicked, so I thought maybe I can just executed the js my self, but I am not sure how to execute the script of buttons , also not sure what script gets called when the button is clicked. 问题是附加了渲染过程的按钮在单击时不会执行按钮的js,所以我想也许我可以自己执行js,但是我不确定如何执行按钮的脚本,也不确定单击按钮时会调用什么脚本。

 <input id="next" name="signIn" class="rc-button rc-button-submit" value="Weiter" type="submit"> 

Use JavascriptExecutor to execute the click event like - 使用JavascriptExecutor执行click事件,例如-

JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.ExecuteScript("$('#next').click();", "");

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

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