Can't press enter in selenium2library

2019-06-14 15:39发布

I'm trying to make a test that will open Facebook, log in and search something. However I'm having trouble getting Facebook to search. Selenium types whatever it needs in the search bar, but I can't find how to locate the search button or press the enter key.

*** 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条回答
Juvenile、少年°
2楼-- · 2019-06-14 15:43

Press Key expects two parameters - the locator, and the actual key; you're calling it with only the latter.

Press Key    name=q    \\13

That should execute pressing an Enter in the search field.

Will it work? I don't use FB, can't tell :)

Add the html of the search button - right click on it, Inspect Element, we might be able to get a locator for it.

查看更多
登录 后发表回答