简体   繁体   中英

Selenium c#: Execute correct jquery

Im trying to execute jquery from selenium to change the visibility of a object, I have the next code but it's not working, does anybody knows the error?

IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
        js.ExecuteScript(                
           "document.querySelector('input[type='file']').style.display = 'block';"
         );

The problem were the quotes, I've already fixed:

IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
        js.ExecuteScript(
         @"document.querySelector('input[type=""file""]').style.display = 'block';"

            );

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