无法在selenium2library中输入

时间:2017-05-04 18:42:36

标签: python selenium robotframework selenium2library

我试图进行测试,打开Facebook,登录并搜索某些内容。但是我在浏览Facebook时遇到了麻烦。 Selenium在搜索栏中输入所需的内容,但我无法找到如何找到搜索按钮或按回车键。

*** Settings ***
Documentation  Tell pui she bitch
Library  Selenium2Library

*** Variables ***

*** Test Cases ***
User must tell pui she bitch
    open browser  http://www.facebook.com
    set browser implicit wait  5
    input text  name=email  *****
    input text  name=pass  ****
    click button  id=u_0_q
    input text  name=q  *****
    press key \\13


    close browser


*** Keywords ***

1 个答案:

答案 0 :(得分:3)

Press Key需要两个参数 - 定位器和实际键;你只用后者来称呼它。

Press Key    name=q    \\13

这应该在搜索栏中按Enter键。

会起作用吗?我不用FB,说不清楚:)。

添加搜索按钮的html - 右键单击​​它,检查元素,我们可能会得到它的定位器。