Selenium: How to copy values from field1 to field2

2019-02-18 18:14发布

问题:

We are recording a test using Selenium IDE in Firefox.

We need to copy a value from a read-only field to an input field.

Is there a direct way I can refer the field or do I have to store and use it. An example would be great.

Thanks.

回答1:

You'll need two commands, one to store and one to retrieve. Assuming the read-only field has a name of Foo and the the input field has a name of Bar, then in the three boxes for the commands:

Command: storeValue
Target: name=Foo
Value: variableName

Command: type
Target: name=Bar
Value: ${variableName}

Alternatively, the source in the file would be:

<tr>
    <td>storeValue</td>
    <td>name=Foo</td>
    <td>variableName</td>
</tr>
<tr>
    <td>type</td>
    <td>name=Bar</td>
    <td>${variableName}</td>
</tr>