简体   繁体   English

为什么我的代码在 Robot Framework 上跳过了一步

[英]Why does my code skip a step on Robot Framework

I'm trying to make an automated test for my company's website.我正在尝试为我公司的网站进行自动化测试。 The code passes my test , but it skips a step while doing it.该代码通过了我的测试,但它在执行时跳过了一个步骤 It is supposed to First delete text from the input area and after that add a new value to that same place .它应该首先从输入区域中删除文本,然后在同一个地方添加一个新值

I have already tried to click the input area and then delete the text with Delete Text Clear Element Text id=bankAccount.iban , but it skips this part我已经尝试单击输入区域,然后使用Delete Text Clear Element Text id=bankAccount.iban ,但它跳过了这一部分

This code is from the Robot Framework此代码来自机器人框架

*** Settings ***
Library           Selenium2Library

*** Variables ***
${Username}       myemailaddress@gmail.com
${Password}       12345678
${Browser}        Chrome
${SiteUrl}        http://our.siteaddress.fi/flfuserct-style/login
${DashboardTitle}    Our title was here
${ExpectedWarningMessage}    IBAN is invalid
${WarningMessage}    Adding a new bank failed!
${BankIban}       FI2112345600000788 (((this is not a real IBAN, so don't worry)))
${Delay1}         3s
${Delay2}         1s
${Delay3}         2s
${Delay4}         2s
${Delay5}         3s
${Delay6}         1s


*** Test Cases ***
Login Should Complete Without Errors, But Changing To A New Bank Should Fail Via Invalid IBAN
    Open Page
    Check Title
    Enter User Name
    Enter Password
    Click Login
    sleep    ${Delay1}
    Click My Info
    sleep    ${Delay2}
    Click Bank Account
    sleep    ${Delay3}
    Click Edit
    sleep    ${Delay4}
    Delete Text
    sleep    ${Delay5}
    Enter IBAN
    Assert Warning Message
    sleep    ${Delay6}
    [Teardown]    Close Browser


*** Keywords ***
Open Page
    open browser    ${SiteUrl}    ${Browser}
    Maximize Browser Window

Check Title
    Title Should be    ${DashboardTitle}

Enter User Name
    Input Text    css=[type="text"]    ${Username}

Enter Password
    Input Text    css=[type="password"]    ${Password}

Click Login
    Click Button    css=[type="submit"]

Click My Info
    Click Element    id=my-info

Click Bank Account
    Click Link    css=[href="/flfuserct-style/users/me/bank-accounts/primary"]

Click Edit
    Click Element    css=.MuiButton-label

Delete Text
    Clear Element Text    id=bankAccount.iban

Enter IBAN
    Input Text    id=bankAccount.iban    ${BankIban}

Assert Warning Message
    Element Text Should Be    id=bankAccount.iban-helper-text    ${ExpectedWarningMessage}    ${WarningMessage}

And this code if from the website如果来自网站,则此代码

<input aria-invalid="true" class="MuiInputBase-input MuiInput-input"
id="bankAccount.iban" name="bankAccount.iban" required="" type="text"
value="FI2112345600000788" aria-describedby="bankAccount.iban-helper-text">

Code from the robot framework ( https://imgur.com/RY7E5h6 )来自机器人框架的代码 ( https://imgur.com/RY7E5h6 )

Code from the log ( https://imgur.com/XESLljF )日志中的代码( https://imgur.com/XESLljF

If you can see those pictures (sorry I'm new here) the first one is from the Robot Framework, showing the message log.如果你能看到这些图片(对不起,我是新来的),第一张来自 Robot Framework,显示了消息日志。 As you can see it passes the test without errors, but it skips the Clear Element Text part.如您所见,它通过了测试而没有错误,但它跳过了Clear Element Text部分。

2nd picture of from the log it says: Clears the value of the text-input-element identified by the locator.日志中的第二张图片显示:清除定位器标识的文本输入元素的值。 But that's not happening.但这并没有发生。 It just writes the IBAN after the existing one, and it should delete it.它只是在现有的 IBAN 之后写入 IBAN,并且应该将其删除。

Also, It seems that I can't do 3 * in a row but Settings, Variables, Test Cases and Keywords have 3 stars此外,我似乎不能连续做 3 *,但设置、变量、测试用例和关键字有 3 颗星

For the Delete Text keyword, I think it's a little more clear if you would use something like对于Delete Text关键字,我认为如果您使用类似的东西会更清楚一点

Input Text id=bankAccount.iban ${EMPTY}

That way, you are actually setting the value of the textfield's string to empty string, and you are sure it will work since the same locator and the same method ( Input Text keyword) surely works on the next step, for adding the actual value (just that instead of adding a value, you're setting this one to Empty String)这样,您实际上将文本字段字符串的值设置为空字符串,并且您确信它会起作用,因为相同的定位器和相同的方法( Input Text关键字)肯定会在下一步中起作用,用于添加实际值(只是你没有添加一个值,而是将这个设置为空字符串)

Include the below for the Delete Text with below code:使用以下代码包括以下Delete Text

Wait Until Element Is Visible    ${element}    timeout=${time}s
Set Focus to Element    ${element}
Click Element    ${element}
Clear Element Text    ${element}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM