2017-05-04 35 views
-2

我試圖做一個測試,將打開Facebook,登錄和搜索的東西。不過,我無法讓Facebook搜索。 Selenium在搜索欄中鍵入所需內容,但我無法找到如何定位搜索按鈕或按Enter鍵。無法在硒庫中按輸入

*** 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需要兩個參數 - 的定位器,和實際密鑰;你只用後者來調用它。

Press Key name=q \\13 

這應該執行在搜索字段中按Enter鍵。

它會工作嗎?我不使用FB,不能說:)

添加搜索按鈕的html - 右鍵單擊​​它,檢查元素,我們可能能夠得到它的定位器。

+0

謝謝,我已經做了你的建議。將嘗試按鍵,看看它是否工作。 –