问题
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