Reputation: 187
I want to select a window from the list of returned windows title in robotFramework, the code is the below:
Partager sur Facebook
${Window1Title}= Get Window Titles
Run Keyword If '${Window1Title}[]' == 'Facebook' ConnexionAndPartageFacebook
Run Keyword If '${Window1Title}' == 'Publier sur Facebook' PartageFacebook
It give me the error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 28: ordinal not in range(128)
How can i select Window 2 from the returned window titles ?
Upvotes: 1
Views: 6498
Reputation: 71
This is an old post, but thought will provide a tip here. It depends on the version of Selenium library being used, the get window titles works perfectly fine in selenium2library but has issue with seleniumlibrary, if the window titles has a special character in them. Look at this issue for more details : https://github.com/robotframework/SeleniumLibrary/issues/1252. This issue has been fixed and works fine in seleniumlibrary.
Back to the question, this is a simple way of choosing the window that is needed:
@{Windowtitles} Get Window Titles
${windowtoopen}= Get From List ${Windowtitles} -1
Select Window Title=${windowtoopen}
This would allow you to choose the window.
Upvotes: 3
Reputation: 1575
Below script will select the "Home" window
@{Window_List} List Windows
${Win_Index}= Get Index From List ${Window_List} Home
Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${Timeout_20s} ${Timeout_2s}
... Select Window ${Window_List[${Win_Index}]}
This can be used as common script to select window by passing window name as parameters
Upvotes: 1
Reputation: 6971
This can be done by referring to the item in the list. More information can be found in the chapter on Variables of excellent Robot Framework Userguide:
Run Keyword If '${Window1Title[1]}' == 'Facebook' ConnexionAndPartageFacebook
Upvotes: 0