Can't press enter in selenium2library

a 夏天 提交于 2020-01-03 06:37:59

问题


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:


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.



来源:https://stackoverflow.com/questions/43790516/cant-press-enter-in-selenium2library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!