0
votes

I am using SapGuiLibrary to automate some tests in SAP GUI screens using the Robot Framework. To identify the elements I am using the Script Tracker and I was able to identify the element I want to interact with, but when I click on it, or change the value of the field I get the error message:

ValueError: Cannot find element with id 'wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/txtLIPSD-G_LFIMG[2,0]'

Here is what I'm doing:

*** Settings ***
Library     SapGuiLibrary
Resource    ../Resource/Login_PartLinQ.robot

*** Variables ***
${Btn_DeleteRow}        wnd[1]/tbar[0]/btn[14]
${SAP_Title}            /app/con[0]/ses[0]/wnd[0]/titl
${Tab_DocsXVendor}      wnd[0]/usr/cntlMEALV_GRID_CONTROL_VL31/shellcont/shell
${Txt_DeliveryQtd}      wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/txtLIPSD-G_LFIMG[2,0]
${Txt_DocCategory}      wnd[0]/usr/ctxtSP$00004-LOW
${Txt_Material}         wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/ctxtLIPS-MATNR[1,0]
${Txt_MaterNumber}      wnd[0]/usr/ctxtS_MATNR-LOW
${Txt_Plant}            wnd[0]/usr/ctxtSP$00023-LOW
${Txt_PurchasDoc}       wnd[0]/usr/ctxtSP$00005-LOW
${Txt_PurchasGroup}     wnd[0]/usr/ctxtSP$00006-LOW
${Txt_SelecParam}       wnd[0]/usr/ctxtSP$00010-LOW

*** Keywords ***
### Given ###
that the user is logged into PartLinQ
  ${title}    Get Value    ${SAP_Title}
  Should Be Equal    ${title}    SAP Easy Access ${SPACE}-${SPACE} User Menu for test ID for automated Test Scripts 1

### When ###
the user update the Business Partner
  Run Transaction     VL31N
  Send Vkey           Shift + F4
  Input Text          ${Txt_MaterNumber}      VO 82713508
  Input Text          ${Txt_PurchasDoc}       1000005844
  Set Focus           ${Txt_PurchasGroup}
  Send Vkey           F2
  Click Element       ${Btn_DeleteRow}
  Set Focus           ${Txt_DocCategory}
  Send Vkey           F2
  Click Element       ${Btn_DeleteRow}
  Set Focus           ${Txt_SelecParam}
  Send Vkey           F2
  Click Element       ${Btn_DeleteRow}
  Set Focus           ${Txt_Plant}
  Send Vkey           F2
  Click Element       ${Btn_DeleteRow}
  Send Vkey           F8
  Select Table Row    ${Tab_DocsXVendor}    0
  Send Vkey           F8
  Input Text          ${Txt_DeliveryQtd}    5

That's what I got from Script Tracker:

$ID = Invoke-Method -object $session -methodName "findById" -methodParameter @("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/txtLIPSD-G_LFIMG[2,0]");
Set-Property -object $ID -propertyName "text" -propertyValue @("5");

1
I see that you made sure ("Should Be Equal") that the current SAP GUI screen is "SAP Easy Access...", but then how do you go to the right screen to "input text" in that not-found field? If you are still on SAP Easy Access screen, then it's normal that the field you mention is not found. - Sandra Rossi
Hi @SandraRossi, I omitted part of my code to be more precise. Don't worry because I'm on the right screen. - Joseilton
@SandraRossi I edited my post and put all my code, but I don't thing its necessary. - Joseilton
I don't have an answer, but I think that it's either related to the name tabpT\01 where \ seems to be removed (SapGuiLibrary bug or is it only when the message is output?), or the subscreen 1202 is not under the tab named tabpT\01 (I guess this may happen because the tabs are dynamically assigned). Maybe you could use Get Value or Take Screenshot to help troubleshooting. - Sandra Rossi
You're right again @Sandra Rossi, thank you very much! The \ is an escape character in the RBF and I had not realized that it was present or that it had been removed, so I put two \\ and the test passed. When I grow up I want to be like you. :-) - Joseilton

1 Answers

1
votes

The problem was that there was a backslash (\) in element_id. The backslash (\) is an escape character in the Robot Framework and was being excluded, so to lie it in the address it is necessary to put one more backslash in the address, that is, \\ so the Robot Framework knows it needs to interpret it instead of discarding it.