简体   繁体   English

如何在C#中使用Selenium WebDriver执行本地javascript文件

[英]How to execute local javascript file using selenium webdriver in C#

I am developing an application where i want to execute a java script file using selenium web driver in C#. 我正在开发一个应用程序,我想在C#中使用Selenium Web驱动程序执行Java脚本文件。 I am keeping the file as a part of application so whenever application launch, i want that js file executed.I already tried placing that js file on server but I don't want that. 我将文件保留为应用程序的一部分,因此每当应用程序启动时,我都希望执行该js文件。我已经尝试过将该js文件放置在服务器上,但我不希望这样做。 I want that js as a part of application. 我希望该js作为应用程序的一部分。

Use the JavascriptExecutor: 使用JavascriptExecutor:

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("[INSER JS HERE]");

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

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