ruby selen
Ruby
code posted
by
georgw
created at 07 Dec 11:17
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
require 'rubygems' require 'selenium-webdriver' require 'watir-webdriver' require 'win32ole' require 'watir-webdriver-performance' #require 'test/unit' include Selenium #driver = Selenium::WebDriver.for :ff profile = WebDriver::Firefox::Profile.new profile["network.proxy.type"] = 1 profile["network.proxy.http"] = "ramkesd018-p.ra.rockwell.com" profile["network.proxy.http_port"] = 3128 driver = WebDriver.for(:firefox, :profile => profile) driver.navigate.to "https://drilling.cloudapp.net/" driver.manage.window.move_to(300, 400) driver.manage.window.resize_to(500, 800) driver.manage.window.maximize driver.navigate.to "https://drilling.cloudapp.net/" puts driver.title if driver.title == "RA Cloud Platform - Sign In" puts "1.Test PASSED. Title is :" + driver.title else puts "1.Test FAILED" end if driver.save_screenshot("RA Cloud Platform - Sign In'.png") puts "Screenshot has been saved" else puts "FAIL > Screenshot has not been saved" end # Login to Google element = driver.find_element(:name, 'Google').click element = driver.find_element(:name, 'Email').send_keys "cloudtester12345" element = driver.find_element(:name, 'Passwd').send_keys "tester12345" if element = driver.find_element(:name, 'signIn').click puts "Prihlaseni se zdarilo" else puts "Chyba prihlaseni" end if driver.title == "Canrig Monitoring Portal" puts "2.Test PASSED" puts driver.title else puts "2.Test FAILED" end sleep 9 if driver.save_screenshot("Canrig Monitoring Portal.png") puts "Obrazek ulozen" else puts "Chyba-obrazek nebyl ulozen" end puts driver.current_url #driver.navigate.to "https://drilling.cloudapp.net/Dashboards/Index.html" #element = driver.find_element(:id, 'dijit__TreeNode_4').click # FILE in menu file = driver.find_element(:xpath=> "//*[@id='dijit_PopupMenuBarItem_0']" ).click if file puts "File value in Menu pressed. " else puts "Unable to find File value" end sleep 1 #SERVER in menu Server = driver.find_element(:xpath=> "//*[@id='dijit_PopupMenuBarItem_1']" ).click if Server puts "Server value in Menu pressed" else puts "Unable to find File value" end sleep 1 # FILE in menu file = driver.find_element(:xpath=> "//*[@id='dijit_PopupMenuBarItem_0']" ).click if file puts "File value in Menu pressed. " else puts "Unable to find File value" end sleep 1 # Expand REPORTS Reports = driver.find_element(:xpath, "//div[@id='dijit__TreeNode_1']/div/img").click if Reports puts "REPORTS expanded" else puts "FAILED to expand REPORTS" end sleep 1 driver.find_element(:css, "span.dijitTreeLabel.dijitTreeLabelFocused").click sleep 1 #PUMP PERFORMANCE Pump_Performance = driver.find_element(:xpath, "//*[@id='dijit__TreeNode_4']/div[1]/span[2]/span").click if Pump_Performance puts "Pump_Performance expanded" else puts "FAILED to expand Pump_Performance" end sleep 1 #PARTS AND SERVICE Parts_Service = driver.find_element(:xpath, "//*[@id='dijit__TreeNode_5']/div[1]/span[2]/span").click if Parts_Service puts "Parts & Service expanded" else puts "FAILED to expand Parts & Service" end sleep 1 #PUMP LOCATION Pump_Location = driver.find_element(:xpath, "//*[@id='dijit__TreeNode_6']/div[1]/span[2]/span").click if Pump_Location puts "Pump Location expanded" else puts "FAILED to expand Pump Location" end sleep 1 #Map filter driver.find_element(:xpath, "//div[@id='mapFilterPane']/div/div/img").click sleep 1 driver.find_element(:xpath, "//div[@id='mapFilterPane']/div/div/img").click sleep 1 e = driver.find_element(:id, 'mapTruckSelect') e.send_keys :arrow_down sleep 1 e.send_keys "Layne", :enter sleep 4 #CIRCLE IN THE MAP #element = driver.find_element(:xpath,"//id='OpenLayers.Layer_506']/svg/g") #dragAndDrop(element,+30,+60) driver.find_element(:xpath, "//div[@id='mapPane']/div[1]/div").click sleep 1 driver.find_element(:xpath, "//div[@id='mapPane']/div[1]/div").click sleep 1 #CLOSE TAB driver.find_element(:xpath, "//div[@id='contentTabs_tablist_map']/span[2]").click sleep 2 element = driver.find_element(:id, 'contentTabs_tablist_parts').click sleep 2 #PUMP PERFORMANCE PANEL OPERATION filters = driver.find_element(:xpath, "//div[@id='partsFilterPane']/div[1]").click sleep 2 consumablestoorder = driver.find_element(:xpath, "//div[@id='partsConsumablePane']/div[1]/div").click sleep 2 filters = driver.find_element(:xpath, "//div[@id='partsFilterPane']/div[1]").click sleep 1 e = driver.find_element(:id, 'partsTruckSelect') e.send_keys :arrow_down sleep 1 e.send_keys "RockyRoad47", :enter sleep 3 consumablestoorder = driver.find_element(:xpath, "//div[@id='partsConsumablePane']/div[1]/div").click sleep 3 consumablestoorder = driver.find_element(:xpath, "//div[@id='partsConsumablePane']/div[1]/div").click sleep 2 #driver.find_element(:xpath, "//div[@id='dojox_grid__View_0']/div/div/div/div[1]/table/tbody/tr/td[1]/input").click #move = driver.find_element(:id, 'partsGridHdr3' # Button ORDER #if driver.find_element(:xpath, "//div[@id='dijit_TitlePane_1']/div[1]").click #puts "Clicked on ORDER" #else #puts "FAILED to click on Order" #end #sleep 1 #if driver.find_element(:id, 'dijit_form_Button_0_label').location_once_scrolled_into_view #puts "Scrolled on button Order" #else #puts "Scrolling on button Order FAILED" #end if driver.find_element(:id,'dijit_form_TextBox_0').send_keys "po number 123456" puts "Text box filled" else puts"FAILED : Text box havent found" end sleep 2 driver.find_element(:id,'dijit_form_Textarea_0').send_keys "bla bla 12345" sleep 2 driver.find_element(:id, 'dijit_form_Button_0_label').click sleep 3 if driver.save_screenshot("FORM.png") puts "Obrazek ulozen" else puts "Chyba-obrazek nebyl ulozen" end driver.find_element(:id, 'dijit_form_Button_1_label').click sleep 2 #CLOSE TAB driver.find_element(:xpath, "//div[@id='contentTabs_tablist_parts']/span[2]").click sleep 3 #PUMP PERFORMANCE TAB driver.find_element(:id, "fleetCustomerSelect").clear driver.find_element(:id, "fleetCustomerSelect").send_keys "Factory", :enter sleep 3 driver.find_element(:id, "fleetCustomerSelect").clear driver.find_element(:id, "fleetCustomerSelect").send_keys "Nabors", :enter sleep 3 driver.find_element(:xpath, "//div[@id='contentTabs_tablist_custom_CustomTab_0']/span[2]").click sleep 3 # close REPORTS driver.find_element(:xpath, "//div[@id='dijit__TreeNode_1']/div/img").click sleep 1 # Expand PUMPS driver.find_element(:xpath, "//div[@id='dijit__TreeNode_2']/div/img").click sleep 3 Pump001 = driver.find_element(:xpath, "//div[@id='dijit__TreeNode_8']/div[1]/span[2]/span").click sleep 10 Pump002 = driver.find_element(:xpath, "//div[@id='dijit__TreeNode_9']/div[1]/span[2]/span").click sleep 10 if driver.save_screenshot("FINAL'.png") puts "Screenshot has been saved" else puts "FAIL > Screenshot has not been saved" end sleep 1 if driver.quit puts "END OF TEST" else puts "CANNOT LEAVE TEST" end |
6.95 KB in 9 ms with coderay