简体   繁体   中英

How to execute javascript for watir webdriver to change text inside a span id

I am using Watir Webdriver selenium and trying to run:

browser.execute_script($("#CSVFileName").text("template.csv"))

I'm trying to execute javascript to change the FileName.csv to template.csv but doesn't appear to be working. Here is the code of the element from the browser.

<div class="uploader">
    <div class="load-line" style="width:100%"></div>
    <span class="name" id="CSVFileName">FileName.csv</span>
</div>

您似乎只是缺少脚本周围的引号-即execute_script需要一个字符串:

browser.execute_script('$("#CSVFileName").text("template.csv")')

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