【发布时间】:2020-05-21 11:48:44
【问题描述】:
我想在 C# 中使用 selenium 执行以下脚本
脚本
$("btn-standard buyButton currency-coins").on('click',function () {
$(".dialog-body .ut-button-group .btn-text").click();})
C# 代码
IWebDriver driver;
driver = new FireFoxdriver()
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
//here I want to integrate the script
js.ExecuteScript(.....)
driver.FindElement(By.XPath("//button[text()[contains(.,'Buy Now')]]")).Click(); //this button has btn-standard buyButton currency-coins class
如何集成脚本?
【问题讨论】:
-
那么
IJavaScriptExecutor.ExecuteScript有什么问题? -
您应该小心,jQuery 已加载到页面上。
-
@Selvin,问题是我不知道如何设置脚本字符串的撇号
-
我的意思是
string script = " here is the problem, I don't know how to convert that script in a string" -
所以问题是关于在C#中转义双引号?填空做一些研究
标签: javascript c# selenium selenium-webdriver