3
votes

I'm writing an acceptance test for web using Robot Framework + Selenium2Library. The point is that web contain some input field that I can not automate (CAPTCHA), and I can't tell my vendor to turn off this feature while running test. So I have to input this field manually. Now I'm doing this:

Create User
    [Arguments]            ${username}    ${password}
    Open Browser           ${URL}         ${BROWSER}
    Input Text             username       ${username}
    Input Text             password       ${password}
    Sleep                  10             # XXX input CAPTCHA manually here!
    Click Button           submit
    Page Should Contain    ${username} has been created.

I've input CAPTCHA when I tell Robot Framework to Sleep 10, so far so good. But I wonder is there anyway to tell Robot Framework to wait indefinitely, then continue automate task after I finish input that CAPTCHA?

3
You could tell it to wait until any number of options before continuing. For example, inputting some random text in a field that's optional or not required. If it were me, I would probably change the order so at the beginning of the test you fill in the captcha, then get it to wait until you put the focus in the username field and have it continue from thereshicky

3 Answers

4
votes

There is a keyword just for this purpose in the Dialog library that comes with Robot Framework.

Execute Manual Step    Please complete the CAPTCHA portion of the form.
3
votes

I can see a few options:

You can remove sleep and button clicking and do them yourself. Then you can use wait until page contains to continue after you has pushed submit button

Create User
    [Arguments]                 ${username}    ${password}
    Open Browser                ${URL}         ${BROWSER}
    Input Text                  username       ${username}
    Input Text                  password       ${password}
    Log                         Waiting for CAPTCHA
    Wait Until Page Contains    ${username} has been created.    timeout=3600

You can also use Pause Execution keyword from Dialogs-library. This pauses execution until you click OK in a popup.

Create User
    [Arguments]                 ${username}    ${password}
    Open Browser                ${URL}         ${BROWSER}
    Input Text                  username       ${username}
    Input Text                  password       ${password}
    Pause Execution             Enter captcha
    Click Button                submit
    Page Should Contain         ${username} has been created.

The most automated way I can think of is to use a CAPTCHA solving service. I believe they have an API where you send screenshot of your page and get a solved CAPTCHA back. I have never tried them and sharing screenshots of your software may not be an option.

0
votes

You can also use the command- get value from user.

It opens the pop-up and tell user to insert the text value(Like enter captcha present at page), when user enters the captcha value and click on ok then this value gets insert into captcha window and next operation begins.

Code is:

    #Use     Library   Dialogs
    open browser     http://sitename     ff
    input text  id=name-id    anytext
    ${Captcha} =  get value from user   Enter Captcha   none    none
    input text   id=captcha-id   ${Captcha}
    click element   id=submit-id

Note: Use "Libray Dialogs" initially