Get Value from ExecuteScript from JavaScriptExecutor

后端 未结 1 1857
孤街浪徒
孤街浪徒 2021-01-16 04:16

I have a issue i need value from

string someValue = ((IJavaScriptExecutor)Global.Driver).ExecuteScript(\"$(\'#publication_title\').val();\");

Console.Write         


        
1条回答
  •  天命终不由人
    2021-01-16 05:13

    string someValue = ((IJavaScriptExecutor)Global.Driver).ExecuteScript("return $('#publication_title').val();");
    

    Is what you are looking for. It needs a little more "pushing" to tell it "get this value and give it back to me".

    I'd also say you probably don't even need to do this. If you are struggling to get the value property of an element, it's better to do:

    element.GetAttribute("value");
    

    0 讨论(0)
提交回复
热议问题