我也有關鍵字「運行關鍵字如果」的問題。 我已經調查了幾乎所有從stackoverflow的文章,並嘗試了很多次不同的解決方案,不幸的是沒有任何改進。 我發佈那篇文章,希望有人會告訴我正確的提示。運行關鍵字如果 - 沒有執行完成時返回OK結果
的問題是在以下幾點:
我嘗試做一個檢查,以檢查是否存在領域,該領域是繼
<input type="text" class="select-dropdown" readonly="true" data-activates="select-options-aaf80655-9ef4-37cc-6026-2f5989e82df1" value="Please select organisation">
如果該字段存在,則應該執行關鍵字「選擇 - ORG「,如果沒有,則跳過。
所以,我試圖操縱顯示下面的代碼(UPD:11.07):
<li class="step active" data-order="1">
<div class="step-title waves-effect"><b>General info</b></div>
<div class="step-content" style="left: 0%; display: block;">
<div class="row">
<div class="input-field col s12">
<div class="btn-types">
<div class="btn-group">
<button type="button" data-activity-type="1" class="btn btn-primary btn-activity-type selected"><span>Event</span></button>
<button type="button" data-activity-type="2" class="btn btn-primary btn-activity-type "><span>Repeating</span></button>
<input type="hidden" id="activity_type" name="activity_type" value="1">
</div>
</div>
</div>
<div class="clearfix"></div>
<br>
<div class="input-field col s12 ">
<div class="select-wrapper"><span class="caret">▼</span>
<input type="text" class="select-dropdown" readonly="true" data-activates="select-options-e1b60306-a7d2-ef9c-ecc9-3df0dec2ac24" value="Please select organisation">
<ul id="select-options-e1b60306-a7d2-ef9c-ecc9-3df0dec2ac24" class="dropdown-content select-dropdown" style="width: 1181px; position: absolute; top: 0px; left: 0px; opacity: 1; display: none;">
<li class=""><span>Please select organisation</span></li>
<li class=""><span>ORG-WITH-IMAGE</span></li>
<li class=""><span>ORG-WITHOUT-IMAGE</span></li>
</ul>
<select id="organisation_id" name="organisation_id" class="initialized">
<option value="0">Please select organisation</option>
<option value="782">ORG-WITH-IMAGE</option>
<option value="783">ORG-WITHOUT-IMAGE</option>
</select>
</div>
<label for="organisation_id">Organisation</label>
</div>
<div class="clearfix"></div>
</li>
機器人框架代碼如下:
*** Settings ***
Resource Settings.robot
Resource Variables.robot
Library OperatingSystem
*** Test Cases ***
Check create Event
Open SiteURL
Login as Provider
Events - Add new
*** Keywords ***
Events - Add new
Sleep 1
Go To ${UrlSite}/cms/activity?t=1
Sleep 1
Click Element xpath=(//a[@class="add-btn-new"])[1]
Sleep 1
Log To Console Checke-one
Sleep 1
Log To Console Check-two
${CycleValue} = Run Keyword And Return Status Element Should Be Visible //input[@class="select-dropdown"][1]
Log To Console Check-three
Sleep 1
Log To Console Check-four
Run keyword If ${CycleValue} == "PASS" Select-ORG
Log To Console Check-five
Select-ORG
Sleep 1
Click Element xpath=(//input[@class="select-dropdown"])[1]
Sleep 1
Click Element xpath=//div[@class="row"]/div/div/ul/li[last()]/span
Sleep 1
The row that need to click is selected
也許是我的環境問題NT:
- robotframework-3.0.2
- 的Python 2.7.11
- OS X埃爾卡皮坦版本。 10.11.6
看起來你可能有一個拼寫錯誤。「Log To Console Checke-one」是Checke結尾的一個額外的e。 – StefanE
這是一個單獨創建的關鍵字,特殊情況下當需要的字段存在時,則「運行關鍵字如果「將執行它。 – Alex
@StefanE,這不是問題,這是我設置的信息。沒關係。 – Alex