# Get Text results in error in case of SVG element

**URL:** <https://forum.robotframework.org/t/get-text-results-in-error-in-case-of-svg-element/1681>\
**Category:** Browser\
**Created:** [26 April 2021 12:54 UTC](https://forum.robotframework.org/t/get-text-results-in-error-in-case-of-svg-element/1681 "2021-04-26T12:54:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JaPyR](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/japyr/32/756_2.png) [@JaPyR](https://forum.robotframework.org/u/JaPyR)\
**Post date:** [26 April 2021 12:54 UTC](https://forum.robotframework.org/t/get-text-results-in-error-in-case-of-svg-element/1681/1 "2021-04-26T12:54:48Z")

</div>

I am doing my first POC with Browser library so I am not sure whether I am doing everything correctly (if what I am doing is supported), so want to double check before submitting issue.

When I am using `Get Text` keyword with SVG element (obtained using `Get Element` keyword) I am getting error:

```nohighlight
local variable 'value' referenced before assignment

```

Minimal Example:

```python
***Settings***
Library Browser timeout=30

***Test Cases***
Demo SVG - Fails
    New Browser firefox headless=${False}
    New Page https://www.highcharts.com/demo/responsive
    ${parents} Get Elements //*[local-name()="g" and contains(@class, "highcharts-legend-item")]
    FOR ${element} IN @{parents}
        ${rect_el} Get Element ${element} >> xpath=./*[local-name()="rect"]
        ${fill} Get Attribute ${rect_el} fill
        ${text_el} Get Element ${element} >> xpath=./*[local-name()="text"]
        ${text} Get Text ${text_el}
    END

```

---

<div class="post-metadata">

**Author:** ![slnecnik](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/slnecnik/32/740_2.png) [@slnecnik](https://forum.robotframework.org/u/slnecnik)\
**Post date:** [29 April 2021 13:48 UTC](https://forum.robotframework.org/t/get-text-results-in-error-in-case-of-svg-element/1681/2 "2021-04-29T13:48:24Z")

</div>

I think you cannot declare a variable inside a loop in RF.  
In RF you should use [Collections library](https://robotframework.org/robotframework/latest/libraries/Collections.html#Append%20To%20List)  
First you “create list” then inside of a loop you will “append to list”

But I am not sure what are you trying to accomplish with that test 🙂 Please provide a little context so I can be more specific.

And CSS selectors enable a bit clearer selector :).  
${parents} = Get Elements g.highcharts-legend-item

---

<div class="post-metadata">

**Author:** ![JaPyR](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/japyr/32/756_2.png) [@JaPyR](https://forum.robotframework.org/u/JaPyR)\
**Post date:** [29 April 2021 14:41 UTC](https://forum.robotframework.org/t/get-text-results-in-error-in-case-of-svg-element/1681/3 "2021-04-29T14:41:36Z")

</div>

Variables inside loops are allowed, it’s not issue. Problem is with `Get Text` keyword. As workaround used `Get Property` keyword and got `textContent`.

---

<div class="post-metadata">

**Author:** ![rasjani](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@rasjani](https://forum.robotframework.org/u/rasjani)\
**Post date:** [1 May 2021 22:04 UTC](https://forum.robotframework.org/t/get-text-results-in-error-in-case-of-svg-element/1681/4 "2021-05-01T22:04:08Z")

</div>

workaround and actual error almost feels like its a bug in the lib.

---

<div class="post-metadata">

**Author:** ![rasjani](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@rasjani](https://forum.robotframework.org/u/rasjani)\
**Post date:** [3 May 2021 07:28 UTC](https://forum.robotframework.org/t/get-text-results-in-error-in-case-of-svg-element/1681/5 "2021-05-03T07:28:58Z")

</div>

Took at look at the code and yeah, it is a bug in Browserlibrary code: [Get text keyword bug · Issue #957 · MarketSquare/robotframework-browser · GitHub](https://github.com/MarketSquare/robotframework-browser/issues/957)

---

<div class="post-metadata">

**Author:** ![JaPyR](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/japyr/32/756_2.png) [@JaPyR](https://forum.robotframework.org/u/JaPyR)\
**Post date:** [4 May 2021 07:22 UTC](https://forum.robotframework.org/t/get-text-results-in-error-in-case-of-svg-element/1681/6 "2021-05-04T07:22:58Z")

</div>

@rasjani Thank you!

---

<div class="post-metadata">

**Author:** ![aaltat](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/aaltat/32/15_2.png) [@aaltat](https://forum.robotframework.org/u/aaltat)\
**Post date:** [11 May 2021 21:26 UTC](https://forum.robotframework.org/t/get-text-results-in-error-in-case-of-svg-element/1681/7 "2021-05-11T21:26:58Z")

</div>

Thank you for reporting the issue. Good news is that issue should be fixed in next release: [Sometimes element text can be empty by aaltat · Pull Request #989 · MarketSquare/robotframework-browser · GitHub](https://github.com/MarketSquare/robotframework-browser/pull/989/files)

---

<div class="post-metadata">

**Author:** ![aaltat](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/aaltat/32/15_2.png) [@aaltat](https://forum.robotframework.org/u/aaltat)\
**Post date:** [12 May 2021 18:41 UTC](https://forum.robotframework.org/t/get-text-results-in-error-in-case-of-svg-element/1681/8 "2021-05-12T18:41:19Z")

</div>

Investigating issue more and found more problems to be fixed. Therefore this is not fixed in the 4.5.0. The 4.5.0 contains only updated Playwright 1.11.0. Will be part of the 4.6.0 release.
