selenium webdriver输入字段,专注于ruby for firefox

时间:2013-09-27 18:17:11

标签: ruby selenium focus webdriver input-field

我目前正在使用selenium webdriver 2.35 for firefox在ruby中编程。我有一个问题,我无法让webdriver正确地集中在输入字段元素上。默认情况下,字段中已填充了一些灰色文本。当用户单击此字段时,该灰色文本应该消失并允许用户键入字段。

使用webdriver,我会将click命令发送到该元素,它会点击,但没有任何东西会在视觉上发生。我还检查了活动元素,实际上它是那个字段(点击元素后)。 (我用它来检查:driver.switch_to.active_element

此外,我会将密钥发送到该字段,它会显示灰色或者附加到默认文本或清除该字段并发送这些密钥

我使用但不起作用的方法

1)driver.find_element(element).click

2)driver.action.move_to.element.click.perform

有没有人有任何建议? (我知道这可能听起来含糊不清,但我可以随意质疑我需要更多信息)

我不确定这是否有帮助,但这里是点击之前的html(在selenium中使用点击功能后也是相同的结果

这是点击之前的html(以及使用selenium点击功能后的结果

<html>
    <td id="ext-gen273" class="x-toolbar-cell input-container">
        <div id="ext-gen274" class="x-form-field-wrap x-form-field-trigger-wrap" style="width: 467px;">
            <input id="ext-comp-1024" class="x-form-text x-form-field autofoo-search-txtbx foo-search-dropdown x-form-empty-field" type="text" name="ext-comp-1024" autocomplete="off" size="24" style="width: 398px;"></input>
        </div>
    </td>
</html>

此html在用户手动点击字段后显示。

<html>
    <td id="ext-gen273" class="x-toolbar-cell input-container">
        <div id="ext-gen274" class="x-form-field-wrap x-form-field-trigger-wrap x-trigger-wrap-focus" style="width: 467px;">
            <input id="ext-comp-1024" class="x-form-text x-form-field autofoo-search-txtbx foo-search-dropdown x-form-focus" type="text" name="ext-comp-1024" autocomplete="off" size="24" style="width: 398px;"></input>
        </div>
    </td>
</html>

我还注意到,在用户手动点击字段后,selenium命令正常工作

0 个答案:

没有答案