|
| 1 | +*** Setting *** |
| 2 | +Documentation These tests must open own browser because windows opened by |
| 3 | +... earlier tests would otherwise be visible to Get Window XXX keywords |
| 4 | +... even if those windows were closed. |
| 5 | +Suite Setup Open 3 Browsers with Windows |
| 6 | +Suite Teardown Close All Browsers |
| 7 | +Resource resource.robot |
| 8 | + |
| 9 | +*** Variables *** |
| 10 | +@{BrowserA_EXP_TITLES}= WindowA1 WindowA2 WindowA3 |
| 11 | +@{BrowserB_EXP_TITLES}= WindowB1 WindowB2 |
| 12 | +@{BrowserC_EXP_TITLES}= WindowC1 |
| 13 | +@{ALL_BROWSERS_EXP_TITLES}= @{BrowserA_EXP_TITLES} @{BrowserB_EXP_TITLES} @{BrowserC_EXP_TITLES} |
| 14 | +@{EXP_ALIASES}= BrowserA BrowserB BrowserC |
| 15 | +@{EXP_IDS}= ${1} ${2} ${3} |
| 16 | + |
| 17 | + |
| 18 | +*** Test Cases *** |
| 19 | +Check Titles of Multiple Browser-Windows |
| 20 | + @{BrowserA_Titles}= Get Window Titles browser=BrowserA |
| 21 | + Should Be Equal ${BrowserA_Titles} ${BrowserA_EXP_TITLES} |
| 22 | + @{BrowserB_Titles}= Get Window Titles browser=BrowserB |
| 23 | + Should Be Equal ${BrowserB_Titles} ${BrowserB_EXP_TITLES} |
| 24 | + @{BrowserC_Titles}= Get Window Titles browser=BrowserC |
| 25 | + Should Be Equal ${BrowserC_Titles} ${BrowserC_EXP_TITLES} |
| 26 | + @{All_Browsers_Titles}= Get Window Titles browser=ALL |
| 27 | + Should Be Equal ${All_Browsers_Titles} ${ALL_BROWSERS_EXP_TITLES} |
| 28 | + |
| 29 | +Check Count of Handle |
| 30 | + Check Handle Count 3 BrowserA |
| 31 | + Check Handle Count 2 BrowserB |
| 32 | + Check Handle Count 1 BrowserC |
| 33 | + Check Handle Count 6 ALL |
| 34 | + |
| 35 | +Check Count of Names |
| 36 | + Check Name Count 3 BrowserA |
| 37 | + Check Name Count 2 BrowserB |
| 38 | + Check Name Count 1 BrowserC |
| 39 | + Check Name Count 6 ALL |
| 40 | + |
| 41 | +Check Count of Identifiers |
| 42 | + Check Identifiers Count 3 BrowserA |
| 43 | + Check Identifiers Count 2 BrowserB |
| 44 | + Check Identifiers Count 1 BrowserC |
| 45 | + Check Identifiers Count 6 ALL |
| 46 | + |
| 47 | +Check Locations |
| 48 | + @{Locations}= Get Locations browser=ALL |
| 49 | + Should Be Equal As Strings @{Locations}[0] ${FRONT_PAGE}javascript/dynamic_content.html?1 |
| 50 | + Should Be Equal As Strings @{Locations}[1] ${FRONT_PAGE}javascript/dynamic_content.html?2 |
| 51 | + Should Be Equal As Strings @{Locations}[2] ${FRONT_PAGE}javascript/dynamic_content.html?3 |
| 52 | + Should Be Equal As Strings @{Locations}[3] ${FRONT_PAGE}javascript/dynamic_content.html?4 |
| 53 | + Should Be Equal As Strings @{Locations}[4] ${FRONT_PAGE}javascript/dynamic_content.html?5 |
| 54 | + Should Be Equal As Strings @{Locations}[5] ${FRONT_PAGE}javascript/dynamic_content.html?6 |
| 55 | + ${count} Get Length ${Locations} |
| 56 | + Should Be Equal As Integers 6 ${count} |
| 57 | + |
| 58 | +Get Browser Ids and Alias |
| 59 | + @{Aliases}= Get Browser Aliases |
| 60 | + Should Be Equal ${Aliases} ${EXP_ALIASES} |
| 61 | + &{Aliases}= Get Browser Aliases |
| 62 | + Should Be Equal ${Aliases.BrowserA} ${1} |
| 63 | + Should Be Equal ${Aliases.BrowserB} ${2} |
| 64 | + Should Be Equal ${Aliases.BrowserC} ${3} |
| 65 | + @{IDs}= Get Browser Ids |
| 66 | + Should Be Equal ${IDs} ${EXP_IDS} |
| 67 | + |
| 68 | +Select Window by Location |
| 69 | + Switch Browser BrowserA |
| 70 | + Switch Window WindowA1 |
| 71 | + Switch Window By Location ${FRONT_PAGE}javascript/dynamic_content.html?5 |
| 72 | + ${location} Get Location |
| 73 | + Should Be Equal ${FRONT_PAGE}javascript/dynamic_content.html?5 ${location} |
| 74 | + Title Should Be WindowB2 |
| 75 | + |
| 76 | +Switch Window to Different Browser |
| 77 | + Switch Browser BrowserC |
| 78 | + Switch Window WindowC1 |
| 79 | + Location Should Be ${FRONT_PAGE}javascript/dynamic_content.html?6 |
| 80 | + Switch Window title:WindowA1 browser=BrowserA |
| 81 | + Location Should Be ${FRONT_PAGE}javascript/dynamic_content.html?1 |
| 82 | + Switch Window url:${FRONT_PAGE}javascript/dynamic_content.html?4 browser=BrowserB |
| 83 | + Title Should Be WindowB1 |
| 84 | + |
| 85 | +Get Specific Locations and Title |
| 86 | + Switch Browser BrowserA |
| 87 | + Switch Window title:WindowA1 |
| 88 | + Location Should Be ${FRONT_PAGE}javascript/dynamic_content.html?1 |
| 89 | + @{Locations}= Get Locations browser=BrowserB |
| 90 | + Should Be Equal @{Locations}[0] ${FRONT_PAGE}javascript/dynamic_content.html?4 |
| 91 | + Should Be Equal @{Locations}[1] ${FRONT_PAGE}javascript/dynamic_content.html?5 |
| 92 | + ${count}= Get Length ${Locations} |
| 93 | + Should Be Equal As Integers ${count} 2 |
| 94 | + @{Titles}= Get Window Titles browser=BrowserC |
| 95 | + Should Be Equal @{Titles}[0] WindowC1 |
| 96 | + ${count}= Get Length ${Titles} |
| 97 | + Should Be Equal As Integers ${count} 1 |
| 98 | + |
| 99 | + |
| 100 | +Fail Switching Window and Locations From Different Browser |
| 101 | + Switch Browser BrowserA |
| 102 | + Switch Window WindowA1 |
| 103 | + ${Error_Msg}= Run Keyword And Expect Error * Switch Window WindowB1 |
| 104 | + Should Be Equal As Strings ${Error_Msg} No window matching handle, name, title or URL 'WindowB1' found. |
| 105 | + ${Error_Msg}= Run Keyword And Expect Error * Get Locations browser=UnknownBrowser |
| 106 | + Should Be Equal As Strings ${Error_Msg} Non-existing index or alias 'UnknownBrowser'. |
| 107 | + ${Error_Msg}= Run Keyword And Expect Error * Get Window Handles browser=${4} |
| 108 | + Should Be Equal As Strings ${Error_Msg} Non-existing index or alias '4'. |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | +*** Keywords *** |
| 113 | +Open 3 Browsers with Windows |
| 114 | + Close All Browsers |
| 115 | + Open Browser With Alias And Title BrowserA WindowA1 1 |
| 116 | + Open New Window and set Title WindowA2 2 |
| 117 | + Open New Window And Set Title WindowA3 3 |
| 118 | + Open Browser With Alias And Title BrowserB WindowB1 4 |
| 119 | + Open New Window And Set Title WindowB2 5 |
| 120 | + Open Browser With Alias And Title BrowserC WindowC1 6 |
| 121 | + |
| 122 | +Open New Window And Set Title |
| 123 | + [Arguments] ${title} ${id} |
| 124 | + Execute Javascript window.open("dynamic_content.html?${id}") |
| 125 | + Switch Window locator=NEW |
| 126 | + Set Window Title ${title} |
| 127 | + |
| 128 | +Open Browser With Alias And Title |
| 129 | + [Arguments] ${alias} ${title} ${id} |
| 130 | + Open Browser ${FRONT_PAGE}javascript/dynamic_content.html?${id} ${BROWSER} alias=${alias} |
| 131 | + Set Window Title ${title} |
| 132 | + |
| 133 | +Set Window Title |
| 134 | + [Arguments] ${title} |
| 135 | + Input Text id:titleChangeTxt ${title} |
| 136 | + Click Button id:titleChangeBtn |
| 137 | + Title Should Be ${title} |
| 138 | + |
| 139 | +Check Handle Count |
| 140 | + [Arguments] ${length} ${browser_alias}=${None} |
| 141 | + @{WinCountBrowser}= Get Window Handles ${browser_alias} |
| 142 | + ${len}= Get Length ${WinCountBrowser} |
| 143 | + Should Be Equal As Integers ${len} ${length} |
| 144 | + |
| 145 | +Check Name Count |
| 146 | + [Arguments] ${length} ${browser_alias}=${None} |
| 147 | + @{WinCountBrowser}= Get Window Names ${browser_alias} |
| 148 | + ${len}= Get Length ${WinCountBrowser} |
| 149 | + Should Be Equal As Integers ${len} ${length} |
| 150 | + |
| 151 | +Check Identifiers Count |
| 152 | + [Arguments] ${length} ${browser_alias}=${None} |
| 153 | + @{WinCountBrowser}= Get Window Identifiers ${browser_alias} |
| 154 | + ${len}= Get Length ${WinCountBrowser} |
| 155 | + Should Be Equal As Integers ${len} ${length} |
| 156 | + |
| 157 | +Switch Window By Location |
| 158 | + [Arguments] ${selected_location} |
| 159 | + @{IDs}= Get Browser Ids |
| 160 | + :FOR ${id} IN @{IDs} |
| 161 | + \ @{locations}= Get Locations browser=${id} |
| 162 | + \ Run Keyword If '${selected_location}' in $locations |
| 163 | + ... Switch Window url:${selected_location} browser=${id} |
0 commit comments