在网站上,有一个由用户通过单击浏览按钮然后选择文件来填充的字段。我不知道如何让 watir 填充它。几年前我们运行了测试用例,发现它browser.fileField(:id,"file01").set(x)
但不再有效。
irb(main):154:0> bowser.fileField(:id,"file01").exists?
NoMethodError: undefined method `fileField' for #<Watir::IE:0x35de4d8>
from (irb):154
from C:/Ruby193/bin/irb:12:in `<main>'
我可以找到它,但还没有比这更远:
irb(main):159:0> browser.form(:id, '104').span(:id, "file_1").exists?
=> true
这是代码:
<form id="104" onsubmit="return validateForm();" method="post" >
<input type="hidden" value="1" name="create">
<input id="external" type="hidden" value="0" name="external">
<table class="text fullWidth" cellspacing="0" summary="Sending Form">
<tbody>
<tr>
<script type="text/javascript">
<tr>
<tr>
<tr>
<tr>
<td class="fRequired">
<td class="fText">
<table class="fInput">
<tbody>
<tr>
<td>
<span id="file_01">
<input id="file01" class="fFile" type="file" onchange="writename(this.value, shortfile1'); return true;" tabindex="2" name="file01">
<span id="shortfile1"> aby.JPG</span>
</span>
<br>
<span id="file_02">
<br>