← Back to team overview

sikuli-driver team mailing list archive

[Question #680320]: SikuliXIDE; Mojave; Robot Framework: TypeError: unsupported operand type(s) for -: 'unicode' and 'int'

 

New question #680320 on Sikuli:
https://answers.launchpad.net/sikuli/+question/680320

I seem to be getting hung up in something that I think ought to be easy, but I've been going round and round with this for a while. I a have function that worked fine in Jython (outside the Robot Framework), but when I put it in the Robot Framework I had to change things up a bit by converting a string back to an integer in order to get the "If, elif, else" to work. I'm attempting to use this function for moving around a table grid so I can write values into the cells. The problem is, the grid movement actually appears to work (because I can see it highlight the next cell I intend to write to), but it throws the following error and fails my keyword. The error is:

TypeError: unsupported operand type(s) for -: 'unicode' and 'int'

FOLLOWING IS ROBOT FRAMEWORK DRIVING IT ALL:

runScript("""
robot
*** Variables ***
${TESTAPP}        "/Applications/Vernier Graphical Analysis.app"
${moveright}        1
${moveleft}        2
${moveup}        3
${movedown}        4
        
*** Settings ***
Library        ./inline/GA4 
Suite Setup    Suite Setup Actions
Suite Teardown    Suite Teardown Actions
Test Teardown    Test Case Tear Down        
*** Test Cases ***
Test Manual Copy and Paste to Cell
    [Documentation]    Test Case to do a manual copy and paste to cell (Table view)
    Log    Executing Manual Copy and Paste to Cell Test
    press manual entry button        
    press view options button        
    select table view                
    initialize table    ${TESTAPP}     
    write to selected cell        2  
    grid movement        ${movedown}        1  


*** Keywords ***
Suite Setup Actions
    Log    Suite Setup Actions done below
    start my application        ${TESTAPP} 
    define application region

Suite Teardown Actions
    Log    Suite Teardown Actions done below
    stop my application        ${TESTAPP}

Test Case Tear Down
    Log    Test Teardown Actions done below
    prep for next test 

""")

FOLLOWING IS THE FUNCTION (I've stripped all out of the Class but that one to shorten it up here):

class GA4(object):

  def grid_movement(self, direction, loopvalue):
    print "Executing 'grid_movement' function"
    movdirection = int(direction)
    while(loopvalue > 0):
      if movdirection == 1:
        type(Key.RIGHT)
      elif movdirection == 2:
        type(Key.LEFT)
      elif movdirection == 3:
        type(Key.UP)
      elif movdirection == 4:
        type(Key.DOWN)
      else:
        break
      loopvalue -= 1
      print loopvalue

FOLLOWING IS THE ROBOT FRAMEWORK OUTPUT: 

Test Execution Log

00:00:13.367SUITE GA4-experimenting
Full Name:	GA4-experimenting
Source:	/Users/labquest_automation/Desktop/SikuliX_Scripts/GA4-experimenting.sikuli.robot/GA4-experimenting.robot
Start / End / Elapsed:	20190418 12:56:33.650 / 20190418 12:56:47.017 / 00:00:13.367
Status:	1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
00:00:02.021SETUP Suite Setup Actions
00:00:01.594TEARDOWN Suite Teardown Actions
00:00:09.550TEST Test Manual Copy and Paste to Cell
Full Name:	GA4-experimenting.Test Manual Copy and Paste to Cell
Documentation:	
Test Case to do a manual copy and paste to cell (Table view)
Start / End / Elapsed:	20190418 12:56:35.869 / 20190418 12:56:45.419 / 00:00:09.550
Status:	FAIL (critical)
Message:	TypeError: unsupported operand type(s) for -: 'unicode' and 'int'
00:00:00.002KEYWORD BuiltIn . Log Executing Manual Copy and Paste to Cell Test
00:00:02.949KEYWORD GA4 . Press Manual Entry Button
00:00:00.770KEYWORD GA4 . Press View Options Button
00:00:02.239KEYWORD GA4 . Select Table View
00:00:03.342KEYWORD GA4 . Initialize Table ${TESTAPP}
00:00:00.174KEYWORD GA4 . Write To Selected Cell 2
00:00:00.062KEYWORD GA4 . Grid Movement ${movedown}, 1
Start / End / Elapsed:	20190418 12:56:45.350 / 20190418 12:56:45.412 / 00:00:00.062
12:56:45.404	INFO	Executing 'grid_movement' function
[log]  TYPE "#DOWN."	
12:56:45.412	FAIL	TypeError: unsupported operand type(s) for -: 'unicode' and 'int'	
00:00:00.004TEARDOWN Test Case Tear Down


-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.