string selectedManagerValue = getElement_RuntimeText(drv, By.XPath("//*[@id='auditManager']/option[@selected='selected']"));
string script = @"var d = document.querySelectorAll('#abcManager/deep/option') ;
for (var i = 0; i < d.length; i++){
if ( d[i].innerText == 'arguments[0]' || d[i].innerText == 'Select')
continue;
else
{d[i].innerText;
break;}
};";
string newManagerValue = (string)js.ExecuteScript(" return "+script, selectedManagerValue);
这是我运行时的代码,它给出了以下错误:
****预期表达,获得关键字&#39; var&#39; (UnexpectedJavaScriptError)****
UnpackAndThrowOnError(OpenQA.Selenium.Remote.Response)}
-(string)js.ExecuteScript(" return "+script, selectedManagerValue) '(string)js.ExecuteScript(" return "+script, selectedManagerValue)' threw an exception of type 'System.InvalidOperationException'
当我在Chrome控制台中执行它时,javascript工作正常。不确定我在这里缺少的是什么。