简体   繁体   English

Selenium + C#:ExecuteAsyncScript无效

[英]Selenium + C#: ExecuteAsyncScript not working

I'm trying to run javascript through Selenium driver. 我正在尝试通过Selenium驱动程序运行javascript。 The executeAsyncScript argument gives the exception that input string is not in correct format. executeAsyncScript参数提供输入字符串格式不正确的异常。 The javascript is in the path provided. javascript在提供的路径中。 The javascript function is actually an onclick that does not take any parameters but returns a value that I want to get for further computation. javascript函数实际上是一个onclick,它不接受任何参数,但返回一个我想要进一步计算的值。

 Driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(5));
           var js = Driver as IJavaScriptExecutor;
     var formobject = js.ExecuteAsyncScript(
                           "var callback = arguments[0];"
                         + "var params = arguments;"
                         + "require(['Recruiting/Modules/CandidateProfile'],function(onPrint){"
                         + "onPrint("
                         + ",callback"
                         + ");});"
                     );

I think your javascript is syntacticly incorrect . 我认为你的JavaScript在语法上不正确的 If you would omit the quotes, you would get: 如果你省略引号,你会得到:

var callback = arguments[0];
var params = arguments;
require(['Recruiting/Modules/CandidateProfile'],function(onPrint){
onPrint(
,callback
);});

See the , after the onPrint and before the callback . ,onPrint和之前callback

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

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