# SAP locator and Robot with python

**URL:** <https://forum.robotframework.org/t/sap-locator-and-robot-with-python/8493>\
**Category:** Libraries\
**Created:** [19 February 2025 15:09 UTC](https://forum.robotframework.org/t/sap-locator-and-robot-with-python/8493 "2025-02-19T15:09:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_duty](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/alex_duty/32/4593_2.png) [@alex\_duty](https://forum.robotframework.org/u/alex_duty)\
**Post date:** [19 February 2025 15:09 UTC](https://forum.robotframework.org/t/sap-locator-and-robot-with-python/8493/1 "2025-02-19T15:09:01Z")

</div>

Hi all!  
I hope anyone using SAP here with robot, namely this is the SapGuiLibrary.  
I have managed to store some variables encapsulated in a class, then referencing those across different files.  
The point is that our SAP application has kind of long locators, which are including the connection, session and window count.  
They looks like this: `f'/app/con[{con}]/ses[{ses}]/wnd[{wnd}]{appendix}'`  
where the appendix is the `element_id` of the SAP GUI element.  
So all good, except when opening a new window, the test is exiting with an error, saying it doesnt find the element with correct locator . The locator sure good, according to the scripting tracker.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [19 February 2025 21:54 UTC](https://forum.robotframework.org/t/sap-locator-and-robot-with-python/8493/2 "2025-02-19T21:54:35Z")

</div>

Hi Tamás,

I don’t do much SAP GUI testing myself, but I I’ll suggest you have a look at the [robosapiens Library](https://github.com/imbus/robotframework-robosapiens) from what I understand it’s designed to make things like this easier.

Otherwise, almost everything in Robot framework can be constructed with variables, so you could create variables like this:

```python
VAR ${SAP_Connection} /app/con[{con}]/ses[{ses}]
VAR ${my_SAP_Window} ${SAP_Connection}/wnd[1]{appendix}

Click Element ${my_SAP_Window}/elementid1

VAR ${next_SAP_Window} ${SAP_Connection}/wnd[2]{appendix}

Click Element ${next_SAP_Window}/elementid2

```

Hope that helps,

Dave.

---

<div class="post-metadata">

**Author:** ![alex\_duty](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/alex_duty/32/4593_2.png) [@alex\_duty](https://forum.robotframework.org/u/alex_duty)\
**Post date:** [25 February 2025 09:56 UTC](https://forum.robotframework.org/t/sap-locator-and-robot-with-python/8493/5 "2025-02-25T09:56:12Z")

</div>

Thanks Dave,  
as I said the path is ok. it was ok. found the issue, let it here in case anyone interested:  
`self.session = self.connection.children(0)`  
where the `children` is set according to the opened window count, so in my case, 1 was the solution, using that session the locator worked just fine.
