我正在尝试从以下位置重命名文件夹:
<li class="selected rename" id="labelset-624" folderid="624" foldertype="labelset" permissionlevel="2" labelsetid="624">
<div class="folder-insert-drop ui-droppable"></div>
<div class="clear"></div>
<div class="folder-item droppable hoverable empty ui-droppable">
<div id="mlink-labelset-624" class="folder-menu-link" data-hasfullperm="true" data-subfoldertype="undefined"></div>
<div class="expander"></div>
<div class="folder-name labelset label-set">New Label Set</div>
<div class="target-bar"></div>
<div class="folder-rename">
<input value="New Label Set" id="folder-rename-624" maxlength="100" type="text">
</div>
使用 Watir-webdriver 使用以下命令:
@b.li(:class, "selected rename").div(:class, "folder-rename").text_field.wait_until_present
@b.li(:class, "selected rename").div(:class, "folder-rename").text_field.set labelsetName
@b.li(:class, "selected rename").div(:class, "folder-rename").text_field.send_keys :return
它给了我以下错误:
Watir::Exception::UnknownObjectException: unable to locate element, using {:class=>"selected rename", :tag_name=>"li"}
当我运行我的测试脚本 (test-unit) 时,我可以看到 labelsetName 的值输入到文本字段中,但它很快消失并恢复为默认值。这会导致send_keys
语句出错。
当我在 irb 中输入相同的命令时,它可以完美运行。我尝试在步骤之间添加长达 15 秒的睡眠,但无济于事。两者有什么不同的工作方式吗?有什么建议可以解决这个问题吗?