Produced by Araxis Merge on 10/12/2018 4:04:44 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Vetlink 2.0.zip\Vetlink 2.0\vetlink-web.zip\vetlink-web\acceptance_test\selenium-ruby\module | DriverUtility.rb | Thu Nov 2 15:14:16 2017 UTC |
| 2 | Vetlink 2.0.zip\Vetlink 2.0\vetlink-web.zip\vetlink-web\acceptance_test\selenium-ruby\module | DriverUtility.rb | Thu Oct 11 20:27:15 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 1254 |
| Changed | 2 | 6 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | require Fi le.dirname (__FILE__) + "/../mo dule/Const ants_Drive r" | |
| 2 | ||
| 3 | module D riverUtili ty | |
| 4 | require 'mongo' | |
| 5 | require 'selenium- webdriver' | |
| 6 | ||
| 7 | include Mongo | |
| 8 | include Constants_ Driver | |
| 9 | ||
| 10 | ||
| 11 | USER_ID = "PATID26 " # "D1234 01" | |
| 12 | ||
| 13 | ||
| 14 | def dete rmineEnvir onment | |
| 15 | ||
| 16 | hostname = " IP " | |
| 17 | puts " DriverUtil ity.determ ineEnviron ment hostn ame=[#{hos tname}]" | |
| 18 | puts " DriverUtil ity.determ ineEnviron ment hostn ame=[#{hos tname}]" | |
| 19 | @WAIT_ 4_BASE_URL _COME_UP = 1 | |
| 20 | @EULA_ SERVICE_PA TH = "/eul a/template " | |
| 21 | ##Eula | |
| 22 | @DO_EU LA_FULL_CH ECK = true #OKK | |
| 23 | ||
| 24 | #Vetli nk uploads folder | |
| 25 | @UPLOA DS_PATH = "#{@BASE_U RL}uploads " | |
| 26 | @ABOUT _PDF = "#{ @UPLOADS_P ATH}/vetli nk.pdf" | |
| 27 | @EULA_ DB_NAME = "eula" # Db that h ouse eula and eulaAp plication collection s | |
| 28 | nodeJ= false #Set to true w hen we don t have vag rant box y et. Make s ure to run nodeJ fir st via com mands cd ~/Projects /vetlink/a pp_test; n ode server .js | |
| 29 | ||
| 30 | $BUILD _PAUSE = 2 # Defaul t to 2 sec onds | |
| 31 | $DB_PA USE = 10 | |
| 32 | $PRINT _DEBUG_MSG S = true | |
| 33 | puts(" HOSTNAME: #{hostname }") | |
| 34 | ||
| 35 | $BUILD _PAUSE = 5 | |
| 36 | ||
| 37 | @HOST = " IP " | |
| 38 | @DB_HOST = " IP " #"localhos t" if use mongo in h ademo serv er and now test buil d server i s back at agilexheal th.com; note: insi de firewal l, no dns, so must u se ip "172 .16.45.59" directly | |
| 39 | @EULA_ HOST = "No t Applicab le" #Get Eula ip s erver from Andy | |
| 40 | @PORT = | |
| 41 | @M ONGO_PORT = "27017" | |
| 42 | @EULA_ PORT = "90 95" | |
| 43 | @BASE_ URL = "htt p://#{@HOS T}/vetlink " | |
| 44 | @LAUNC H_PAD_URL = "http:// #{@HOST}/l aunchpad/" | |
| 45 | @WAIT_ 4_BASE_URL _COME_UP = 1 | |
| 46 | ||
| 47 | puts(" After dete rming the environmen t, @HOST i s [#{@HOST }], @BASE_ URL=#{@BAS E_URL}") | |
| 48 | end | |
| 49 | ||
| 50 | ||
| 51 | ||
| 52 | ||
| 53 | def getD riverBased OnHost | |
| 54 | #Need to call de termineEnv ironment f irst befor e calling this metho d | |
| 55 | ||
| 56 | if @RU NNING_ON_I E9_WIN7 | |
| 57 | @dri ver = Sele nium::WebD river.for :ie | |
| 58 | puts ("Setting Driver for IE") | |
| 59 | else | |
| 60 | @dri ver = Sele nium::WebD river.for :firefox | |
| 61 | puts ("Setting Driver for FIREFOX") | |
| 62 | end | |
| 63 | end | |
| 64 | ||
| 65 | ||
| 66 | ||
| 67 | ||
| 68 | def init ializeConf igurations (fromLaun chpad=fals e) | |
| 69 | determ ineEnviron ment | |
| 70 | initia lizeConfig WithFireFo xProfile | |
| 71 | ||
| 72 | i=0 | |
| 73 | numTri es = 1 # TBR - Shou ld set to 1 | |
| 74 | putd(" About to t ry [#{numT ries}] tim es to brin g up vetli nk with fr omLaunchpa d=[#{fromL aunchpad}] & @BASE_U RL[#{@BASE _URL}] - @ WAIT_4_BAS E_URL_COME _UP=#{@WAI T_4_BASE_U RL_COME_UP }") | |
| 75 | !numTr ies.times{ | |
| 76 | i=i+ 1 | |
| 77 | j=0 | |
| 78 | begi n | |
| 79 | if ( !fromLa unchpad ) | |
| 80 | puts("init ializeConf igurations -Loading @ BASE_URL # {@BASE_URL }") | |
| 81 | @driver.ge t(@BASE_UR L) | |
| 82 | el se | |
| 83 | puts("init ializeConf igurations -Loading $ LAUNCH_PAD _URL #{@LA UNCH_PAD_U RL}") | |
| 84 | @driver.ge t(@LAUNCH_ PAD_URL) | |
| 85 | en d | |
| 86 | !2 .times{ br eak if (ge tEulaHeadi ng() == "E nd User Li cense Agre ement"); j =j+1; puts ("#{j}:#{@ BASE_URL} not loaded yet, slee p for #{@W AIT_4_BASE _URL_COME_ UP} second s"); sleep @WAIT_4_B ASE_URL_CO ME_UP } | |
| 87 | pu ts("1.A- i nitializeC onfigurati ons- with i=#{i}, j= #{j}") | |
| 88 | resc ue | |
| 89 | pu ts("1.B- i nitializeC onfigurati ons -with i=#{i}, j= #{j} - Res cue pausin g @WAIT_4_ BASE_URL_C OME_UP=#{@ WAIT_4_BAS E_URL_COME _UP}") | |
| 90 | pa use @WAIT_ 4_BASE_URL _COME_UP | |
| 91 | end | |
| 92 | } | |
| 93 | puts(" initialize Configurat ions -with i =#{i} - Rescue pa using @WAI T_4_BASE_U RL_COME_UP =#{@WAIT_4 _BASE_URL_ COME_UP}") | |
| 94 | ||
| 95 | @drive r.manage.t imeouts.im plicit_wai t = IMPLIC IT_WAIT_FO R_WEB_ELEM ENT_DEFAUL T | |
| 96 | @accep t_next_ale rt = true | |
| 97 | @verif ication_er rors = [] | |
| 98 | ||
| 99 | end | |
| 100 | ||
| 101 | ||
| 102 | ||
| 103 | def init ializeConf igurations NoClear () | |
| 104 | determ ineEnviron ment #Def ine to use IE or Fir eFox first | |
| 105 | getDri verBasedOn Host #The n get appr opriate dr iver for I E or FF | |
| 106 | @drive r.get(@BAS E_URL) | |
| 107 | ||
| 108 | @drive r.manage.t imeouts.im plicit_wai t = IMPLIC IT_WAIT_FO R_WEB_ELEM ENT_DEFAUL T | |
| 109 | @accep t_next_ale rt = true | |
| 110 | @verif ication_er rors = [] | |
| 111 | end | |
| 112 | ||
| 113 | ||
| 114 | #Caller should onl y call thi s method f or FireFox environme nt only | |
| 115 | def init ializeConf igWithFire FoxProfile () | |
| 116 | putd(" Running Fi refox with Profile") | |
| 117 | @FIREF OX_PROFILE _PATH = Fi le.dirname (__FILE__) + "/../fi refoxProfi le" | |
| 118 | profil e = Seleni um::WebDri ver::Firef ox::Profil e.new(@FIR EFOX_PROFI LE_PATH) | |
| 119 | profil e['browser .cache.dis k.enable'] = false | |
| 120 | profil e['browser .cache.mem ory.enable '] = false | |
| 121 | profil e['browser .cache.off line.enabl e'] = fals e | |
| 122 | profil e['network .http.use- cache'] = false | |
| 123 | @drive r = Seleni um::WebDri ver.for :f irefox, :p rofile => profile | |
| 124 | @drive r.manage.w indow.maxi mize | |
| 125 | @drive r.manage.t imeouts.pa ge_load = 300 | |
| 126 | @drive r.manage.t imeouts.im plicit_wai t = IMPLIC IT_WAIT_FO R_WEB_ELEM ENT_DEFAUL T | |
| 127 | @drive r.manage.d elete_all_ cookies | |
| 128 | @drive r.get(@BAS E_URL) | |
| 129 | @accep t_next_ale rt = true | |
| 130 | @drive r.manage.t imeouts.im plicit_wai t = IMPLIC IT_WAIT_FO R_WEB_ELEM ENT_DEFAUL T | |
| 131 | @verif ication_er rors = [] | |
| 132 | end | |
| 133 | ||
| 134 | ||
| 135 | ||
| 136 | def quit Driver() | |
| 137 | @drive r.quit | |
| 138 | emptyL ist = [] | |
| 139 | @verif ication_er rors.shoul d == empty List | |
| 140 | end | |
| 141 | ||
| 142 | ||
| 143 | ||
| 144 | ||
| 145 | def open UrlInNewTa b(url) | |
| 146 | #handl es of all existing w indows b4 opening ne w window | |
| 147 | active WindowHand leList = @ driver.win dow_handle s | |
| 148 | #Open new tab | |
| 149 | if (@R UNNING_ON_ MAC or @RU NNING_ON_M AC_AT_HOME ) | |
| 150 | #Mus t open a n ew window NOT new ta b in brows er because ruby wont treat new tab as ne w window | |
| 151 | putd ("Its a MA C: send_ke ys([:comma nd, 'n']") | |
| 152 | @dri ver.find_e lement(:xp ath, "//bo dy" ).send _keys([:co mmand, 'n' ]) # com mand-n for Mac | |
| 153 | else | |
| 154 | putd ("Its a PC : send_key s([:contro l, 'n']") | |
| 155 | @dri ver.find_e lement(:cl ass, "cont ainer").se nd_keys [: control, ' n'] # con trol-n by default | |
| 156 | end | |
| 157 | handle OfNewWindo w=nil | |
| 158 | pause 0.5 | |
| 159 | putd(" after open up new wi ndow, Loop through [ #{@driver. window_han dles.count }] window handles th at @driver returns") | |
| 160 | @drive r.window_h andles.eac h do |hand le| | |
| 161 | putd ("switchin g to handl e...#{hand le}") | |
| 162 | @dri ver.switch _to.window handle | |
| 163 | this HandleIsHa ndleOfNewW indow = tr ue | |
| 164 | acti veWindowHa ndleList.e ach_with_i ndex do |a ctiveHandl e, i| | |
| 165 | pu td("#{hand le}: a han dle of exi sting wind ow?") | |
| 166 | if (handle = = activeHa ndle) | |
| 167 | putd(" Y es-Skip-ha ndle of ex isting win dow #{(i+1 )}th ") | |
| 168 | thisHandle IsHandleOf NewWindow = false | |
| 169 | break | |
| 170 | en d | |
| 171 | ||
| 172 | end #of activ eWindowHan dleList lo op | |
| 173 | if ( thisHandle IsHandleOf NewWindow) | |
| 174 | pu td(" No -Handle of newly cre ated windo w found!") | |
| 175 | ha ndleOfNewW indow = ha ndle | |
| 176 | br eak | |
| 177 | end | |
| 178 | end # of all win dow handle s list tha t driver r eturns | |
| 179 | if (ha ndleOfNewW indow != n il) | |
| 180 | putd ("switchin g to handl eOfNewWind ow[#{handl eOfNewWind ow}]") | |
| 181 | @dri ver.switch _to.window handleOfN ewWindow | |
| 182 | putd ("and fill ing it wit h this url [#{url}]") | |
| 183 | @dri ver.get(ur l) | |
| 184 | else | |
| 185 | putd ("Failed t o open a n ew window[ #{handleOf NewWindow} ]") | |
| 186 | end | |
| 187 | return (handleOf NewWindow) | |
| 188 | end | |
| 189 | ||
| 190 | ||
| 191 | ||
| 192 | def getC urrentURL( ) | |
| 193 | return @driver.c urrent_url | |
| 194 | end | |
| 195 | ||
| 196 | ||
| 197 | ||
| 198 | def goto Home(baseU rl) | |
| 199 | @drive r.get(base Url) | |
| 200 | end | |
| 201 | ||
| 202 | ||
| 203 | #Get <ti le> tag un der <head> section < title clas s="ng-bind ing">Veter an Link</t itle> | |
| 204 | def getP ageTitle() | |
| 205 | wait = Selenium: :WebDriver ::Wait.new (:timeout => 30) | |
| 206 | wait.u ntil {@dri ver.title} | |
| 207 | return @driver.t itle | |
| 208 | end | |
| 209 | ||
| 210 | ||
| 211 | #Get tex t of id "t itle" | |
| 212 | def getT itleById() | |
| 213 | return @driver.f ind_elemen t(:id, TIT LE_ID).tex t | |
| 214 | end | |
| 215 | ||
| 216 | ||
| 217 | ||
| 218 | #VetLink has heade r with thi s class | |
| 219 | def getP ageHeaderT ext() | |
| 220 | return getTitleB yId() | |
| 221 | end | |
| 222 | ||
| 223 | ||
| 224 | ||
| 225 | ||
| 226 | def relo adPage() | |
| 227 | puts(" In reloadP age()") | |
| 228 | @drive r.find_ele ment(:xpat h, "//body " ).send_k eys(:f5) | |
| 229 | pause 03 | |
| 230 | end | |
| 231 | alias re freshPage reloadPage | |
| 232 | ||
| 233 | ||
| 234 | ||
| 235 | def goto BottomOfPa ge() | |
| 236 | 5.time s do | |
| 237 | @dri ver.find_e lement(:xp ath, "//bo dy" ).send _keys(:pag e_down) | |
| 238 | paus e 0.1 | |
| 239 | end | |
| 240 | end | |
| 241 | ||
| 242 | ||
| 243 | ||
| 244 | def rest artBrowser | |
| 245 | quitDr iver() | |
| 246 | initia lizeConfig urationsNo Clear() | |
| 247 | @mainP age = site GetMainPag e() | |
| 248 | end | |
| 249 | ||
| 250 | ||
| 251 | #Vetlink | |
| 252 | def tapO nDSLogonBu tton | |
| 253 | @drive r.find_ele ment(:id, "dslogon-b utton").cl ick; | |
| 254 | pause 0.5 | |
| 255 | end | |
| 256 | ||
| 257 | ||
| 258 | ||
| 259 | ||
| 260 | #Vetlink | |
| 261 | def acce ptEulaClic kOnDSLogon Go2_LoginP age | |
| 262 | putd(" acceptEula ClickOnDSL ogonGo2_Lo ginPage") | |
| 263 | ||
| 264 | @drive r.manage.d elete_all_ cookies | |
| 265 | @drive r.find_ele ment(:id, TITLE_ID). text.shoul d == "Vete ran Link" | |
| 266 | eulaPa ge = siteG etEulaPage () | |
| 267 | mainpa ge = eulaP age.clickA ccept #to get to DS Logon Page | |
| 268 | assert Title4VetL inks | |
| 269 | putd(" acceptEula ClickOnDSL ogonGo2_Lo ginPage: AT DSLOGON page now, about to click on D SLogon but ton to bri ng up MAE LOgin scre en ") | |
| 270 | dsLogo nPage = ma inpage.cli ckOnDSLogo n() | |
| 271 | pause 0.5 | |
| 272 | return dsLogonPa ge | |
| 273 | ||
| 274 | end | |
| 275 | ||
| 276 | ||
| 277 | ||
| 278 | def getE lement(how , what) | |
| 279 | elemen t = @drive r.find_ele ment(how, what) | |
| 280 | return element | |
| 281 | end | |
| 282 | ||
| 283 | def getE lements(ho w, what) | |
| 284 | ||
| 285 | elemen ts = [] | |
| 286 | elemen ts = @driv er.find_el ements(how , what) | |
| 287 | return elements | |
| 288 | end | |
| 289 | ||
| 290 | ||
| 291 | def getT extForElem ent(pId) | |
| 292 | elemen t = @drive r.find_ele ment(:id, pId) | |
| 293 | #puts "Element T ext is : " + element .text | |
| 294 | return element.t ext.strip | |
| 295 | end | |
| 296 | ||
| 297 | def getT extForElem ent(how, w hat) | |
| 298 | elemen t = @drive r.find_ele ment(how, what) | |
| 299 | #puts "Element T ext is : " + element .text | |
| 300 | return element.t ext.strip | |
| 301 | end | |
| 302 | ||
| 303 | def getT extsForEle ments(how, what) | |
| 304 | elemen ts = @driv er.find_el ements(how , what) | |
| 305 | texts = [] | |
| 306 | for i in 1..elem ents.lengt h | |
| 307 | elem ent = elem ents[i] | |
| 308 | text s[i] = ele ment.text. strip | |
| 309 | end | |
| 310 | ||
| 311 | return texts | |
| 312 | end | |
| 313 | ||
| 314 | ||
| 315 | ||
| 316 | def getE ulaHeading () | |
| 317 | return getTextFo rElement(: css, "div. panel-head ing h2") | |
| 318 | end | |
| 319 | ||
| 320 | #Vetlink | |
| 321 | def acc eptEulaGo2 _DSLogonPa ge() | |
| 322 | puts " [DriverUti lity..acce ptEulaGo2D SLogonPage ]" | |
| 323 | @drive r.manage.d elete_all_ cookies | |
| 324 | !15.ti mes{ break if (getEu laHeading( ) == EULA_ HEADER); p ause 3} | |
| 325 | eulaPa ge = siteG etEulaPage () | |
| 326 | eulaPa ge.clickAc cept | |
| 327 | mainPa ge = siteG etMainPage () | |
| 328 | puts(" Accept Eul a Then Got o DSLogon Page - Sho uld displa y Vetlink DSLogon Pa ge - Retur ning VetLi nk_MainPag e - ") | |
| 329 | return mainPage | |
| 330 | end | |
| 331 | ||
| 332 | ||
| 333 | ||
| 334 | #======= ========== ========== ========== == | |
| 335 | def logi nToHomePag e | |
| 336 | mainpa ge = siteG etMainPage () | |
| 337 | assert Title4VetL inks | |
| 338 | ||
| 339 | eulaPa ge = siteG etEulaPage () | |
| 340 | eulaPa ge.clickAc cept | |
| 341 | assert Title4VetL inks | |
| 342 | ||
| 343 | dsLogo nPage = ma inpage.cli ckOnDSLogo n() | |
| 344 | return dsLogonPa ge.loginAs TestUser() ; | |
| 345 | end | |
| 346 | ||
| 347 | ||
| 348 | def logi nSkipSetup AndGotoHom ePage(over duedays=-1 ) | |
| 349 | puts " loginSkipS etupAndGot oHomePage overdueday s=[#{overd uedays}]" | |
| 350 | @drive r.manage.d elete_all_ cookies | |
| 351 | mainpa ge = siteG etMainPage () | |
| 352 | assert Title4VetL inks | |
| 353 | eulaPa ge = siteG etEulaPage () | |
| 354 | eulaPa ge.clickAc cept | |
| 355 | assert Title4VetL inks | |
| 356 | dsLogo nPage = ma inpage.cli ckOnDSLogo n() | |
| 357 | welcom ePage = ds LogonPage. loginAsTes tUserToWel comePage(U SER_ID) | |
| 358 | pause 0.5 | |
| 359 | return welcomePa ge.tapOnEx it | |
| 360 | end | |
| 361 | ||
| 362 | ||
| 363 | ||
| 364 | def dump Page (msg= "DriverUti lity.dumpP age") | |
| 365 | puts " '#{msg}=[# {@driver.f ind_elemen t(:xpath, '/html/bod y').text}] " | |
| 366 | end | |
| 367 | ||
| 368 | ||
| 369 | ||
| 370 | def dump PageSource | |
| 371 | # puts "'#{msg}= [#{@driver .find_elem ent(:xpath , '/html/b ody').text }]" | |
| 372 | # puts "'#{msg}= [#{@driver .find_elem ent(:xpath , '/html/b ody').text }]" | |
| 373 | puts " DUMPING $P AGE_SOURCE =[#{@drive r.page_sou rce}]" | |
| 374 | end | |
| 375 | ||
| 376 | ||
| 377 | ||
| 378 | ||
| 379 | ||
| 380 | def clea rPatientTr iggers | |
| 381 | puts " DriverUtil ity.clearP atientTrig gers" | |
| 382 | mongo_ client = M ongoClient .new(@HOST , @MONGO_P ORT) | |
| 383 | db = m ongo_clien t.db("vetl ink") | |
| 384 | coll = db.collec tion("pati entTrigger ") | |
| 385 | coll.r emove({"pa tientId" = > {'$ne' = > "0"}}) | |
| 386 | mongo_ client.clo se | |
| 387 | end | |
| 388 | ||
| 389 | ||
| 390 | ||
| 391 | ||
| 392 | def getC urrentWind owHandle | |
| 393 | return @driver.w indow_hand le | |
| 394 | end | |
| 395 | ||
| 396 | ||
| 397 | ||
| 398 | ||
| 399 | def swit chToNextWi ndow | |
| 400 | curren tWindowHan dle = getC urrentWind owHandle | |
| 401 | retHan dle = curr entWindowH andle | |
| 402 | if (@d river.wind ow_handles .count == 1) | |
| 403 | puts "Only 1 w indow, ret urn curren t handle.. ." | |
| 404 | retu rn retHand le #If onl y 1 window , return h andle of c urrent one | |
| 405 | end | |
| 406 | @drive r.window_h andles.eac h do |hand le| | |
| 407 | retH andle = ha ndle | |
| 408 | #pau se 0.5 | |
| 409 | #put s "switchi ng handle. .." | |
| 410 | @dri ver.switch _to.window handle | |
| 411 | #put s handle | |
| 412 | #put s "current url=[#{ge tCurrentUR L()}]" | |
| 413 | brea k if handl e != curre ntWindowHa ndle | |
| 414 | end | |
| 415 | if ( r etHandle ! = nil) | |
| 416 | swit chWindow(r etHandle) | |
| 417 | end | |
| 418 | return retHandle | |
| 419 | end | |
| 420 | ||
| 421 | ||
| 422 | ||
| 423 | def clos eCurrentWi ndow | |
| 424 | @drive r.close | |
| 425 | end | |
| 426 | ||
| 427 | ||
| 428 | ||
| 429 | def swit chWindow(h andle) | |
| 430 | @drive r.switch_t o.window h andle | |
| 431 | end | |
| 432 | ||
| 433 | ||
| 434 | def upda te_all_dat es_to_30_d ays_past | |
| 435 | mongo_ client = M ongoClient .new(@HOST , @MONGO_P ORT) | |
| 436 | db = m ongo_clien t.db("vetl ink") | |
| 437 | contro lTestScore = db.coll ection('co ntrolTestS core') | |
| 438 | thirty DaysAgo = formatDate Time(addDa ys(getToda yInZeroTim eUTC, -30) ) | |
| 439 | puts " [#{thirtyD aysAgo}]" | |
| 440 | contro lTestScore .update( { :_id => { '$exists' => true }} , | |
| 441 | { '$set' => {'scoreDat e' => thir tyDaysAgo }}, | |
| 442 | { :multi => true, :up sert => fa lse} ) | |
| 443 | mongo_ client.clo se | |
| 444 | end | |
| 445 | ||
| 446 | ||
| 447 | def upda te_all_set reminder(s tate) | |
| 448 | mongo_ client = M ongoClient .new(@HOST , @MONGO_P ORT) | |
| 449 | db = m ongo_clien t.db("vetl ink") | |
| 450 | contro lTestScore = db.coll ection('co ntrolTestS core') | |
| 451 | contro lTestScore .update( { :_id => { '$exists' => true }} , | |
| 452 | { '$set' => {'reminder ' => state }}, | |
| 453 | { :multi => true, :up sert => fa lse} ) | |
| 454 | mongo_ client.clo se | |
| 455 | end | |
| 456 | ||
| 457 | def upda te_score_d ays(parmSc ore, parmD ays) | |
| 458 | sign = parmScore .to_i | |
| 459 | absSco re = sign. abs | |
| 460 | score = sign | |
| 461 | days = parmDays | |
| 462 | puts " update..da ys=[#{days }]" | |
| 463 | newDat e = forma tDateTime( addDays(ge tTodayInZe roTimeUTC, days)) | |
| 464 | puts " update..ne wDate=[#{n ewDate}]" | |
| 465 | ||
| 466 | mongo_ client = M ongoClient .new(@HOST , @MONGO_P ORT) | |
| 467 | db = m ongo_clien t.db("vetl ink") | |
| 468 | contro lTestScore = db.coll ection('co ntrolTestS core') | |
| 469 | ||
| 470 | if sig n < 0 | |
| 471 | cont rolTestSco re.update( {"patient Id" => USE R_ID, 'to talScore' => {'$ne' => absScor e}}, \ | |
| 472 | {'$s et' => {'s coreDate' => newDate }}, \ | |
| 473 | { :m ulti => tr ue, :upser t => false } ) | |
| 474 | else | |
| 475 | puts "else [#{ score}]" | |
| 476 | cont rolTestSco re.update( {"patient Id" => USE R_ID, 'tot alScore' = > score}, \ | |
| 477 | {'$s et' => {'s coreDate' => newDate }}, \ | |
| 478 | { :m ulti => fa lse, :upse rt => fals e} ) | |
| 479 | end | |
| 480 | ||
| 481 | # db.c ontrolTest Score.upda te ({"pati entId" : " D123401", "totalScor e" : 13}, | |
| 482 | #{ $se t: { score Date: "201 4-01-01T00 :00:00.000 Z" } }) | |
| 483 | mongo_ client.clo se | |
| 484 | end | |
| 485 | ||
| 486 | ||
| 487 | def getT odayInZero TimeUTC | |
| 488 | # Get current ti me into ar ray | |
| 489 | # form at is [sec ,min,hour, day,month, year,wday, yday,isdst ,zone] | |
| 490 | a = Ti me.now.utc .to_a | |
| 491 | # Zero out sec, min, hrs p ositions | |
| 492 | a[0] = 0 | |
| 493 | a[1] = 0 | |
| 494 | a[2] = 0 | |
| 495 | # Conv ert it to date | |
| 496 | return Time.utc( *a) | |
| 497 | end | |
| 498 | ||
| 499 | ||
| 500 | ||
| 501 | def addD ays(t, d) | |
| 502 | # Conv ert days i nto second s and add it to date | |
| 503 | return t+(d*8640 0) | |
| 504 | end | |
| 505 | ||
| 506 | ||
| 507 | def form atDateTime AMPM(t) | |
| 508 | return t.strftim e("%m/%d/% Y %l:%M:%S %P").upca se.gsub(/ /," ") | |
| 509 | end | |
| 510 | ||
| 511 | def form atDateTime (t) | |
| 512 | return t.strftim e("%Y-%m-% dT%H:%M:%S .000Z") | |
| 513 | end | |
| 514 | ||
| 515 | def form atDate(t) | |
| 516 | return t.strftim e("%-m/%-d /%Y") | |
| 517 | end | |
| 518 | ||
| 519 | ||
| 520 | ||
| 521 | def getB odyContent () | |
| 522 | return @driver.f ind_elemen t(:xpath, '/html/bod y').text | |
| 523 | end | |
| 524 | ||
| 525 | ||
| 526 | def is_e lement_pre sent(how, what) | |
| 527 | begin | |
| 528 | elem ent = @dri ver.find_e lement(how , what) | |
| 529 | retu rn true | |
| 530 | rescue Exception =>e | |
| 531 | retu rn false | |
| 532 | end | |
| 533 | end | |
| 534 | ||
| 535 | def exec uteJquery( jqueryStr) | |
| 536 | @drive r.execute_ script(jQu ery(jquery Str)) | |
| 537 | end | |
| 538 | ||
| 539 | def find (locator) | |
| 540 | @drive r.find_ele ment locat or | |
| 541 | end | |
| 542 | ||
| 543 | def clic k_element_ how_what(h ow,what) | |
| 544 | @drive r.find_ele ment(how, what).clic k | |
| 545 | end | |
| 546 | ||
| 547 | def clic k_element( locator) | |
| 548 | puts " Clicking o n this loc ator: #{lo cator}" | |
| 549 | find(l ocator).cl ick | |
| 550 | end | |
| 551 | ||
| 552 | def veri fy_text_is _visible(l ocator,tex t) | |
| 553 | wait_f or_element _to_load(l ocator) | |
| 554 | puts " Verifying this text: #{text} d oes displa y for this locator: #{locator} " | |
| 555 | elemen t = find(l ocator) | |
| 556 | return element.t ext.strip. should == text | |
| 557 | end | |
| 558 | ||
| 559 | def veri fy_text_is _not_visib le(locator ,text) | |
| 560 | puts " Verifying this text: #{text} d oes not di splay for this locat or: #{loca tor}" | |
| 561 | elemen t = find(l ocator) | |
| 562 | return element.t ext.strip. should_not == text | |
| 563 | end | |
| 564 | ||
| 565 | def veri fy_element _is_visibl e(locator) | |
| 566 | begin | |
| 567 | puts "Verifyin g this loc ator: #{lo cator} doe s display" | |
| 568 | find (locator). displayed? .should == true | |
| 569 | retu rn true | |
| 570 | rescue Selenium: :WebDriver ::Error::N oSuchEleme ntError=>e | |
| 571 | retu rn true.sh ould == fa lse | |
| 572 | end | |
| 573 | end | |
| 574 | ||
| 575 | def veri fy_element _is_not_vi sible(loca tor) | |
| 576 | begin | |
| 577 | find( locator).d isplayed?. should == false | |
| 578 | retur n true | |
| 579 | rescue Selenium:: WebDriver: :Error::No SuchElemen tError=>e | |
| 580 | retur n true.sho uld == tru e | |
| 581 | end | |
| 582 | end | |
| 583 | ||
| 584 | def ente r_text(loc ator,text) | |
| 585 | find(l ocator).se nd_key(tex t) | |
| 586 | end | |
| 587 | ||
| 588 | def wait _for(secon ds) | |
| 589 | Seleni um::WebDri ver::Wait. new(timeou t: seconds ).until { yield } | |
| 590 | end | |
| 591 | ||
| 592 | def open URL(url) | |
| 593 | @drive r.get(url) | |
| 594 | end | |
| 595 | ||
| 596 | def isEl ementVisib le(locator ) | |
| 597 | begin | |
| 598 | elem ent = find (locator) | |
| 599 | retu rn element .displayed ? | |
| 600 | rescue Exception =>e | |
| 601 | retu rn false | |
| 602 | end | |
| 603 | end | |
| 604 | ||
| 605 | def wait _for_eleme nt_to_load (locator) | |
| 606 | sleep 5 | |
| 607 | puts " Waiting fo r this loc ator to be visible o n the page : #{locato r}" | |
| 608 | if isE lementVisi ble(locato r) | |
| 609 | retu rn true | |
| 610 | else | |
| 611 | rais e Selenium ::WebDrive r::Error:: NoSuchElem entError | |
| 612 | end | |
| 613 | sleep 5 | |
| 614 | end | |
| 615 | ||
| 616 | def get_ text_for_a ny_locator (locator) | |
| 617 | return find(loca tor).text | |
| 618 | end | |
| 619 | ||
| 620 | def remo veJumpScre en | |
| 621 | @drive r.execute_ script("$( '.containe r-fluid'). css('overf low', 'vis ible');") | |
| 622 | end | |
| 623 | ||
| 624 | def rspe cAssertCon tains(expe ctedValue, value) | |
| 625 | value. should inc lude(expec tedValue) | |
| 626 | end | |
| 627 | ||
| 628 | ||
| 629 | ||
| 630 | end |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.