我试图用机器人框架运行一些测试,然后在某些元素可见后我想做点什么:
这是我尝试过的:
Page Should Contain Element ${TRAIN_LABEL}
element should be visible ${TRAIN_LABEL}
Wait Until Keyword Succeeds ${RETRY_TIMEOUT} ${RETRY_INTERVAL} Wait Until Element is Visible ${TRAIN_LABEL}
我的TRAIN_LABEL变量:
$ {TRAIN_LABEL} = xpath = // * [@ id ='trainHeader'并且包含(@ data-train-id,'548')]
但是当我运行测试时,它给了我:
AttributeError:开始于
错误。
我该如何解决?
html:
<div class="fleetTrainCell" data-train-id="548">
<div id="trainHeader" class="fleetTrainInfoRow fleetTrainHeader" onclick="showTrainDetails(this.getAttribute('data-train-id'))" data-train-id="548">
<span id="name" class="fleetTrainName">UK390002</span>
</div>
<div class="fleetTrainInfoRow fleetTrainTopRow">
<div class="empty fleetTrainCellIcon" title=""></div>
<div class="fleetTrainCellIcon empty"></div>
<div class="fleetTrainCellIcon empty"></div>
<div class="fleetTrainCellIcon">
<a href="#" onclick="showTrainDetails(this.getAttribute('data-train-id'));onAddMaintenanceEventsClicked();" data-train-id="548">
<img id="addMaintEventIcon" title="Add Maintenance Events" src="/App_Themes/Alstom/Icons/datebox-icon-enabled.png" style="border-width:0px;">
</a>
</div>
</div>
<div id="trainImageCell" title="Critical" class="fleetTrainImageCell redBackground" onclick="showTrainView(this.getAttribute('data-train-id'))" data-train-id="548" alarms="redBackground">
<img id="image" class="fleetTrainImage" src="../../../App_Themes/Alstom/Icons/Trains/train-Red.png" style="border-width:0px;">
</div>
<div class="fleetTrainInfoRow fleetTrainBottomRow">
<div class="fleetTrainCellIcon">
<a href="#" onclick="showTrainDetails(this.getAttribute('data-train-id'));showTrainSummary(this.getAttribute('data-train-id'), 'UK390002');" data-train-id="548">
<img id="noInfoIcon" title="Summary" src="/App_Themes/Alstom/Icons/trains/info.png" style="border-width:0px;">
</a>
</div>
<div class="fleetTrainCellIcon">
<a id="link" class="clickableNotes" href="#" onclick="showNotes(548, 1);return(false);"><img id="img" title="Planning Note: a" class="notesExist" src="../../../App_Themes/Alstom/Icons/planning-note-new-icon.png" alt="Planning Note: a" style="border-width:0px;"></a>
</div>
<div class="fleetTrainCellIcon">
<a id="link" class="clickableNotes" href="#" onclick="showEngineeringNotes(548);return(false);"><img id="img" title="Engineering Notes: 700" class="notesExist" src="../../../App_Themes/Alstom/Icons/engineering-note-icon-new.png" alt="Engineering Notes: 700" style="border-width:0px;"></a>
</div>
<div class="maintenanceRequiredIcon fleetTrainCellIcon" title="Anomalies Detected" onclick="showEngineeringNotes(this.getAttribute('data-train-id'), 2);" data-train-id="548">
<span class="trainAnomalyCount">9+</span>
</div>
</div>
</div>
´´´更详细的测试:
*** Variables ***
&{ENGINEER_ADMIN_USER_3} username=leonel password=Lenel@19 [email protected] language=pt-TP language_t=pt_PT role=system-engineer
# train
&{Train_1} train_id=UK390001
&{Train_2} train_id=UK390002
*** Test Cases ***
Should be able to see train color red on UK390002
[Tags] DEBUG
[Template] Should be able to see train color red on UK390002
${FLEET_PAGE_URL} ${ENGINEER_ADMIN_USER_3} ${Train_2}
*** Keywords ***
Should be able to see train color red on UK390002
[Arguments] ${FLEET_PAGE_URL} ${user} ${train}
Go to Login Page ${FLEET_PAGE_URL}
Login With Correct Credentials ${FLEET_PAGE_URL} ${user}
Locate train by id ${train} grid
Logout
Locate train by id
[Arguments] ${train} ${type}
Locate train ${train}
Validate train ${train} ${type}
Locate train
[Arguments] ${train}
Wait Until Page Does Not Contain ${LOADING}
sleep 2s
Page Should Contain Element ${TRAIN_LABEL}
Element Should Be Visible ${TRAIN_LABEL}
Wait Until Keyword Succeeds ${RETRY_TIMEOUT} ${RETRY_INTERVAL} Wait Until Element is Visible ${TRAIN_LABEL}
${Train_ID}= Get Text ${TRAIN_LABEL}
log to console train id: ${Train_ID}
should be equal ${train.train_id} ${Train_ID}
Wait Until Keyword Succeeds ${RETRY_TIMEOUT} ${RETRY_INTERVAL} Get Element Attribute ${TRAIN_IMAGE} src
${Train_Color}= Get Element Attribute ${TRAIN_IMAGE} src
should be equal ${Train_Color} ${TRAIN_IMAGE_COLOR}
Wait Until Page Does Not Contain ${LOADING}
测试存在/在以下位置停止:>>
Page Should Contain Element ${TRAIN_LABEL}
OR
Element Should Be Visible ${TRAIN_LABEL}
OR
Wait Until Keyword Succeeds ${RETRY_TIMEOUT} ${RETRY_INTERVAL} Wait Until Element is Visible ${TRAIN_LABEL}
这三个关键字都不起作用
我正在尝试使用机器人框架运行一些测试,然后在某些元素可见后我想做点什么:这就是我尝试的:页面应包含元素$ {TRAIN_LABEL}元素应为...