简体   繁体   中英

javascript .click() no work in chrome driver

this is my code:

String script = "document.getElementById('"+Sendcontrol+"').click();";
((IJavaScriptExecutor)driver).ExecuteScript(script);

but it show

Script execution failed.has no method 'click'

So,how can I solve this problem?

Try onclick() , instead of click() .

document.getElementById method returns DOM Element , which does not have "click" method you were trying to call.

Error is rather self-explanatiory. In chrome not every arbitrary element has method click .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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