【问题标题】:How to edit a web element attribute value in c# using selenium如何使用 selenium 在 C# 中编辑 Web 元素属性值
【发布时间】:2017-04-16 18:52:57
【问题描述】:

示例:

<input type="text" id="cargo_q" autocomplete="off" value="5.5"/> 如何使用 selenium web driver 改变“value”属性的值

有没有类似的方法: IWebElement search_cargo =driver.FindElement(By.Id("cargo_q"))); search_cargo.setAttribute(属性名,属性新值); " ?

【问题讨论】:

    标签: javascript c# selenium-webdriver


    【解决方案1】:

    使用 JavascriptExecutor 类:

    JavascriptExecutor js = (JavascriptExecutor) driver; //Driver is the WebDriver object
    js.executeScript("document.getElementById('cargo_q').setAttribute('value', '10')");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-18
      • 2019-04-21
      • 1970-01-01
      • 2017-01-18
      • 2018-11-03
      • 2011-08-11
      • 1970-01-01
      • 2015-02-21
      相关资源
      最近更新 更多