0
votes

I'm having some trouble writing a robot-selenium test for an angularJs-based app. It looks something like this:

Open Browser To Login Page
    Open Browser  ${login}  ${browser}
    Maximize Browser Window
    Set Selenium Speed  ${sel_speed}
    Wait Until Page Contains  Username

Input Username  [Arguments]  ${username}
    Input Text  ${username}

Input Password  [Arguments]  ${password}
    Input Text  ${password}

Submit Login
    Click Button   css=button

The problem is that the input fields get filled but when the button is clicked angular indicates that nothing was entered into the input boxes. I've seen that a work around in selenium is to use the sendKeys method. Robot-Selenium doesn't expose that directly but you can emulate with the Press Key keyword but there are other issues with that.

Does anyone have a tried and true method for getting this to work? Or is no one else having trouble with it?

1

1 Answers

1
votes

The solution I found was to use the Execute Javascript keyword to use angular itself to set the values in the fields. I created a keyword to do this in a generalized way:

Input Angular  [Arguments]  ${locator}  ${value}
    Execute Javascript   var el1 = window.angular.element(window.$('#${locator}'));  el1.val('${value}'); el1.controller('ngModel').$setViewValue(el1.val());