无法修复:属性错误:开头为



我尝试使用机器人框架运行一些测试,我想在某个元素可见后做一些事情:

这是我尝试过的:

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'and contains(@data-train-id,'548'(]

但是当我运行测试时,它给了我:

属性错误:开头为

错误。

我该如何解决这个问题?

.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=leonel@criticalsoftware.com           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}

Element Should Be Visible  ${TRAIN_LABEL}

Wait Until Keyword Succeeds  ${RETRY_TIMEOUT}  ${RETRY_INTERVAL}  Wait Until Element is Visible  ${TRAIN_LABEL}

这 3 个关键字都不起作用

信息有限,但我会尝试:

您定义了${TRAIN_LABEL} = xpath=//*[@id='trainHeader'and contains(@data-train-id,'548')]

如果上述内容在变量部分,则在${TRAIN_LABEL}后面的可选=符号之后至少应有 2 个空格。如果它不在"变量"部分中,则无法像这样分配。您需要使用Set Variable关键字:

${TRAIN_LABEL}    Set Variable    xpath=//*[@id='trainHeader'and contains(@data-train-id,'548')]

最新更新