L
L
leksoQA2017-04-19 15:50:51
Python
leksoQA, 2017-04-19 15:50:51

How to extract a substring from a string inside which double and single quotes, Robot Framework?

Good afternoon.
There is a need to extract a substring, in autotests on the Robot Framework.
I get the string itself using the Get Element Attribute keyword.
The problem is that the result is a string:

"PrimeFaces.ab({s:"mForm:j_idt242",e:"click",p:"mForm:j_idt242"});;;window.open('https://auction-sandbox.openprocurement.org/tenders/fb5bc41429774f178605639783e62027','_blank')"

And when I try to extract a substring with the Get Substring keyword, it gives an error that the syntax of the string is incorrect. I understand that this is as a result of the string having both single and double quotes. In the interpreter, when I tried to assign this string to a variable, it also swears.
Tried to play around with triple quotes, didn't work either. The Robot Framework does not understand a variable like '''${url}'''.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
gill-sama, 2017-04-19
@gill-sama

a = """
"PrimeFaces.ab({s:"mForm:j_idt242",e:"click",p:"mForm:j_idt242"});;;window.open('https://auction-sandbox.openprocurement.org/tenders/fb5bc41429774f178605639783e62027','_blank')"

"""

another option is escaping quotes so that the interpreter parses correctly, you have a problem in a piece of json
I have no experience with robotFramework, maybe knowledgeable people know a more normal way out when working with a framework.

L
leksoQA, 2017-04-19
@leksoQA

The problem is that I get the string using the Robot-a keyword, and immediately assign it to a variable. And when I tried to frame this variable in triple quotes in order to extract a substring from it later, Robot simply did not understand what it was.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question