[英]Can not Execute JavaScript command using Selenium WebDriver in C#
我無法使用 selenium Web 驅動程序執行 js 命令。 例如,我對這個 URL 使用了 3 種方式,但它們都返回 null。
web.FindElementByJs("StackExchange.init.length");
IJavaScriptExecutor js = (IJavaScriptExecutor)web;
string title = (string)js.ExecuteScript("StackExchange.init.length");
web.ExecuteJavaScript("StackExchange.init.length");
我得到它! 對於對象,我應該使用“窗口”。
IJavaScriptExecutor js = (IJavaScriptExecutor)web;
string title = (string)js.ExecuteScript("return window.StackExchange.init.length");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.