Hi there,
I've Problems with the following Keywords (Part of Testcases)
Grep Password "${user}"
Sleep 5.0
@{titles} Get Window Titles
:FOR ${title} IN @{titles}
\ Log ${title}
\ ${match}= Evaluate re.search('(Firmenname: - .*)','${title}') re
\ Run Keyword If ${match} Assign Popup Title ${match}
Select Window ${POPUP TITLE}
.
.
.
Assign Popup Title
[Arguments] ${matchObject}
${popUpTitle}= Evaluate ${matchObject}.group(1) re
Set Test Variable ${POPUP TITLE} ${popUpTitle}
What I'm trying to do is to switch to some popup I opened from my main window. The Problem is that the title of the popup changes each time the parent page is loaded and the popup is opened again. So my way is to get all titles of all available Windows after opening the popup and then get the actual title by doing an robotframework builtin eval with python's re Engine. I can't do this by the whole bunch of "should" or "should not" keywords, because of all the windows titles, only one is matching!
Now I've problems getting the "real" text from the _sre.SRE_Match object which I get assigned to ${match}.
My first attempt was to just say
\ ${match}= Evaluate re.search('(Firmenname: - .*)','${title}').group(1) re
but then where is again a problem because of the titles not matching (they don't have a method "group(1)"). So I ended up with trying to evaluate conditional and do the assignment in a custom keyword. But this ends up in:
20140204 14:25:42.945 : INFO : Slept 5 seconds
20140204 14:25:43.483 : INFO :
Altogether 2 items.
1: XXXXXXXXXXXXXXXX
2: Firmenname: - PPza9
20140204 14:25:43.484 : INFO : @{titles} = [ XXXXXXXXXXXXXXXX | Firmenname: - PPza9 ]
20140204 14:25:43.485 : INFO : XXXXXXXXXXXXXXXX
20140204 14:25:43.487 : INFO : ${match} = None
20140204 14:25:43.489 : INFO : Firmenname: - PPza9
20140204 14:25:43.490 : INFO : ${match} = <_sre.SRE_Match object at 0x000000000471D300>
20140204 14:25:43.496 : FAIL : Evaluating expression '<_sre.SRE_Match object at 0x000000000471D300>.group(1)' failed: SyntaxError: invalid syntax (<string>, line 1)
Ending test: TestPI.Testsuite.Fachadmin.Test Search User
So my question again: "How can I get the matching String in robotframework on basis of the match object I already have (or think to have)
Any other suggestions are also welcome of how to Switch to a popup when only the first part of the popup title is known at test start time.
greetings
Jürgen