Best Selenium code snippet using Selenium.WebDriver.send_keys
Class - Jobs Resource.rb
Source:Class - Jobs Resource.rb
...218 loopcount = 15219 f = 0220 frameloopcount = 10221 select_customer = @driver.find_element(CUSTOMER_SEARCH_FIELD)222 select_customer.send_keys(selectcustomer)223 sleep(1)224 @driver.action.send_keys(:enter).perform225 sleep(1)226 select_customer_next = @driver.find_element(CUSTOMER_NEXT_BTN)227 select_customer_next.click228 loop do229 i += 1230 loop do231 f += 1232 begin233 @driver.switch_to.default_content234 @driver.switch_to.frame(0)235 rescue Selenium::WebDriver::Error::NoSuchFrameError236 false237 end238 break239 if f == frameloopcount240 raise FrameError241 end242 end243 begin244 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)245 wait2.until {@driver.find_element(NAME_FIELD).displayed?}246 rescue Selenium::WebDriver::Error::TimeoutError247 false248 end249 if250 begin251 @driver.find_element(NAME_FIELD).displayed? == true252 rescue Selenium::WebDriver::Error::NoSuchElementError253 false254 end255 break256 end257 if i == loopcount258 raise FrameError259 end260 end261 end262 def dev_select_customer(selectcustomer)263 i = 0264 loopcount = 5265 f = 0266 frameloopcount = 10267 select_customer = @driver.find_element(CUSTOMER_SEARCH_FIELD)268 select_customer.send_keys(selectcustomer)269 sleep(2)270 @driver.action.send_keys(:enter).perform271 sleep(2)272 select_customer_next = @driver.find_element(CUSTOMER_NEXT_BTN)273 select_customer_next.click274 loop do275 i += 1276 loop do277 f += 1278 begin279 @driver.switch_to.default_content280 @driver.switch_to.frame(0)281 rescue Selenium::WebDriver::Error::NoSuchFrameError282 false283 end284 break285 if f == frameloopcount286 raise FrameError287 end288 end289 begin290 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)291 wait2.until {@driver.find_element(NAME_FIELD).displayed?}292 rescue Selenium::WebDriver::Error::TimeoutError293 false294 end295 if296 begin297 @driver.find_element(NAME_FIELD).displayed? == true298 rescue Selenium::WebDriver::Error::NoSuchElementError299 false300 end301 break302 end303 if i == loopcount304 raise FrameError305 end306 end307 end308 def top()309 top_record = @driver.find_element(TOP_JOB)310 end311 def top_refnumber()312 top_refnumber = @driver.find_element(TOP_REFNUMBER)313 end314 def top_status()315 top_refnumber = @driver.find_element(TOP_STATUS)316 end317 def top_type()318 top_refnumber = @driver.find_element(TOP_TYPE)319 end320 def top_open()321 i = 0322 loopcount = 5323 wait = Selenium::WebDriver::Wait.new(:timeout => 5)324 wait.until {@driver.find_element(TOP_REFNUMBER).displayed?}325 top_refnumber = @driver.find_element(TOP_REFNUMBER)326 top_refnumber.click327 loop do328 i += 1329 @driver.switch_to.frame(0)330 begin331 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)332 wait2.until {@driver.find_element(NAME_FIELD).displayed?}333 rescue Selenium::WebDriver::Error::TimeoutError334 false335 end336 if337 begin338 @driver.find_element(NAME_FIELD).displayed? == true339 rescue Selenium::WebDriver::Error::NoSuchElementError340 false341 end342 break343 end344 if i == loopcount345 raise FrameError346 end347 end348 end349 def top_actions()350 wait = Selenium::WebDriver::Wait.new(:timeout => 5)351 wait.until {@driver.find_element(TOP_JOB_ACTIONS).displayed?}352 top_actions = @driver.find_element(TOP_JOB_ACTIONS)353 top_actions.click354 end355 def actions_createactivity()356 i = 0357 loopcount = 5358 wait = Selenium::WebDriver::Wait.new(:timeout => 5)359 wait.until {@driver.find_element(ACTIONS_CREATEACTIVITY).displayed?}360 top_createactivity = @driver.find_element(ACTIONS_CREATEACTIVITY)361 top_createactivity.click362 loop do363 i += 1364 @driver.switch_to.frame(0)365 begin366 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)367 wait2.until {@driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed?}368 rescue Selenium::WebDriver::Error::TimeoutError369 false370 end371 if372 begin373 @driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed? == true374 rescue Selenium::WebDriver::Error::NoSuchElementError375 false376 end377 break378 end379 if i == loopcount380 raise FrameError381 end382 end383 end384 def actions_createinvoice()385 i = 0386 loopcount = 5387 wait = Selenium::WebDriver::Wait.new(:timeout => 5)388 wait.until {@driver.find_element(ACTIONS_CREATEINVOICE).displayed?}389 top_createinvoice = @driver.find_element(ACTIONS_CREATEINVOICE)390 top_createinvoice.click391 @driver.switch_to.alert.accept rescue Selenium::WebDriver::Error::NoAlertOpenError392 loop do393 i += 1394 @driver.switch_to.frame(0)395 begin396 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)397 wait2.until {@driver.find_element(INVOICE_PONUMBER_FIELD).displayed?}398 rescue Selenium::WebDriver::Error::TimeoutError399 false400 end401 if402 begin403 @driver.find_element(INVOICE_PONUMBER_FIELD).displayed? == true404 rescue Selenium::WebDriver::Error::NoSuchElementError405 false406 end407 break408 end409 if i == loopcount410 raise FrameError411 end412 end413 end414 def actions_documents()415 #Only available in grid actions416 i = 0417 loopcount = 5418 wait = Selenium::WebDriver::Wait.new(:timeout => 5)419 wait.until {@driver.find_element(ACTIONS_DOCUMENTS).displayed?}420 top_documents = @driver.find_element(ACTIONS_DOCUMENTS)421 top_documents.click422 loop do423 i += 1424 @driver.switch_to.frame(0)425 begin426 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)427 wait2.until {@driver.find_element(DOCUMENTS_SHOWHIDE_UPLOADER).displayed?}428 rescue Selenium::WebDriver::Error::TimeoutError429 false430 end431 if432 begin433 @driver.find_element(DOCUMENTS_SHOWHIDE_UPLOADER).displayed? == true434 rescue Selenium::WebDriver::Error::NoSuchElementError435 false436 end437 break438 end439 if i == loopcount440 raise FrameError441 end442 end443 end444 def actions_printemail()445 i = 0446 loopcount = 5447 wait = Selenium::WebDriver::Wait.new(:timeout => 5)448 wait.until {@driver.find_element(ACTIONS_PRINTEMAIL).displayed?}449 top_printemail = @driver.find_element(ACTIONS_PRINTEMAIL)450 top_printemail.click451 loop do452 i += 1453 @driver.switch_to.frame(0)454 begin455 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)456 wait2.until {@driver.find_element(PRINTEMAIL_PDF_CHECKBOX).displayed?}457 rescue Selenium::WebDriver::Error::TimeoutError458 false459 end460 if461 begin462 @driver.find_element(PRINTEMAIL_PDF_CHECKBOX).displayed? == true463 rescue Selenium::WebDriver::Error::NoSuchElementError464 false465 end466 break467 end468 if i == loopcount469 raise FrameError470 end471 end472 end473 def actions_duplicatejob()474 i = 0475 loopcount = 5476 wait = Selenium::WebDriver::Wait.new(:timeout => 5)477 wait.until {@driver.find_element(ACTIONS_DUPLICATEJOB).displayed?}478 top_duplicate = @driver.find_element(ACTIONS_DUPLICATEJOB)479 top_duplicate.click480 loop do481 i += 1482 @driver.switch_to.frame(0)483 begin484 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)485 wait2.until {@driver.find_element(NAME_FIELD).displayed?}486 rescue Selenium::WebDriver::Error::TimeoutError487 false488 end489 if490 begin491 @driver.find_element(NAME_FIELD).displayed? == true492 rescue Selenium::WebDriver::Error::NoSuchElementError493 false494 end495 break496 end497 if i == loopcount498 raise FrameError499 end500 end501 end502 def actions_makeinactive()503 currenttopref = @driver.find_element(TOP_REFNUMBER).text504 wait = Selenium::WebDriver::Wait.new(:timeout => 5)505 wait.until {@driver.find_element(ACTIONS_MAKEINACTIVE).displayed?}506 top_makeinactive = @driver.find_element(ACTIONS_MAKEINACTIVE)507 top_makeinactive.click508 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)509 wait2.until {@driver.find_element(PUSH_CONFIRM).displayed?}510 confirm = @driver.find_element(PUSH_CONFIRM)511 confirm.click512 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)513 wait3.until {@driver.find_element(TOP_REFNUMBER).text != currenttopref}514 end515 def search_job(searchname)516 wait = Selenium::WebDriver::Wait.new(:timeout => 5)517 wait.until {@driver.find_element(SEARCH_FIELD).displayed?}518 job_search = @driver.find_element(SEARCH_FIELD)519 job_search.send_keys(searchname)520 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)521 wait2.until {@driver.find_element(SEARCH_BTN).displayed?}522 search_confirm = @driver.find_element(SEARCH_BTN)523 search_confirm.click524 wait3 = Selenium::WebDriver::Wait.new(:timeout => 10)525 wait3.until {@driver.find_element(TOP_JOB).text.downcase.include?(searchname.downcase)}526 end527 def search_jobid(searchname)528 i = 0529 loopcount = 5530 loop do531 wait = Selenium::WebDriver::Wait.new(:timeout => 5)532 if533 begin534 wait.until {@driver.find_element(ID_COLUMN).displayed?} == true535 rescue Selenium::WebDriver::Error::StaleElementReferenceError536 false537 end538 break539 if i == loopcount540 raise StaleError541 end542 end543 end544 job_search = @driver.find_element(ID_COLUMN)545 job_search.send_keys(searchname)546 @driver.action.send_keys(:enter).perform547 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)548 wait2.until {@driver.find_element(TOP_REFNUMBER).text.include?(searchname)}549 end550 def search_jobid_field()551 field = @driver.find_element(ID_COLUMN)552 end553 def search_jobname(searchname)554 i = 0555 loopcount = 5556 loop do557 wait = Selenium::WebDriver::Wait.new(:timeout => 5)558 if559 begin560 wait.until {@driver.find_element(NAME_COLUMN).displayed?} == true561 rescue Selenium::WebDriver::Error::StaleElementReferenceError562 false563 end564 break565 if i == loopcount566 raise StaleError567 end568 end569 end570 job_search = @driver.find_element(NAME_COLUMN)571 job_search.send_keys(searchname)572 @driver.action.send_keys(:enter).perform573 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)574 wait2.until {@driver.find_element(TOP_JOB).text.downcase.include?(searchname.downcase)}575 end576 def search_jobname_field()577 field = @driver.find_element(NAME_COLUMN)578 end579 def search_reset()580 currentrecords = @driver.find_element(class: "Counter_Message").text581 wait = Selenium::WebDriver::Wait.new(:timeout => 5)582 wait.until {@driver.find_element(RESET_BTN).displayed?}583 search_reset = @driver.find_element(RESET_BTN)584 search_reset.click585 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)586 wait2.until {@driver.find_element(class: "Counter_Message").text != currentrecords}587 end588 def grid_options()589 wait = Selenium::WebDriver::Wait.new(:timeout => 5)590 wait.until {@driver.find_element(GRID_OPTIONS_DROPDOWN).displayed?}591 grid_options = @driver.find_element(GRID_OPTIONS_DROPDOWN)592 grid_options.click593 end594 def export_jobs()595 wait = Selenium::WebDriver::Wait.new(:timeout => 5)596 wait.until {@driver.find_element(EXPORT_JOBS).displayed?}597 export_jobs = @driver.find_element(EXPORT_JOBS)598 export_jobs.click599 sleep(2)600 end601 def show_inactives()602 wait = Selenium::WebDriver::Wait.new(:timeout => 5)603 wait.until {@driver.find_element(SHOW_INACTIVES).displayed?}604 show_inactives = @driver.find_element(SHOW_INACTIVES)605 show_inactives.click606 end607 def grid_total()608 gridtotal = @driver.find_element(GRID_TOTAL)609 end610 def resource_performance()611 navigationStart = @driver.execute_script("return window.performance.timing.navigationStart")612 responseStart = @driver.execute_script("return window.performance.timing.responseStart")613 domComplete = @driver.execute_script("return window.performance.timing.domComplete")614 loadPerformance = domComplete - navigationStart615 wait = Selenium::WebDriver::Wait.new(:timeout => 20)616 wait.until {@driver.find_element(GRID_TOTAL).text != "0 records"}617 jobs_records = @driver.find_element(GRID_TOTAL)618 jobs_count = jobs_records.text619 print "Jobs: \n"620 print "%s \n" % jobs_count621 print "Load Time: %s ms \n\n" % loadPerformance622 end623 #CSS Methods: Popup624 def name(jobname)625 job_name = @driver.find_element(NAME_FIELD)626 job_name.send_keys(jobname)627 end628 def location(locationselect)629 dropdown_list = @driver.find_element(LOCATION_DROPDOWN)630 options = dropdown_list.find_elements(tag_name: 'option')631 options.each {|option| option.click if option.text == (locationselect)}632 end633 def type(typeselect)634 dropdown_list = @driver.find_element(TYPE_DROPDOWN)635 options = dropdown_list.find_elements(tag_name: 'option')636 options.each {|option| option.click if option.text == (typeselect)}637 end638 def customer(customername)639 customer_name = @driver.find_element(CUSTOMER_FIELD)640 customer_name.send_keys(customername)641 end642 def patrol(patrolname)643 patrol_name = @driver.find_element(PATROL_FIELD)644 patrol_name.send_keys(patrolname)645 end646 def estimate(estimatename)647 estimate_name = @driver.find_element(ESTIMATE_FIELD)648 estimate_name.send_keys(estimatename)649 end650 def po_number(ponumber)651 po_number = @driver.find_element(PONUMBER_FIELD)652 po_number.send_keys(ponumber)653 end654 def account_executive(accountexecutive)655 dropdown_list = @driver.find_element(ACCOUNT_EXECUTIVE_DROPDOWN)656 options = dropdown_list.find_elements(tag_name: 'option')657 options.each {|option| option.click if option.text == (accountexecutive)}658 end659 def nte(ntefield)660 po_number = @driver.find_element(NTE_FIELD)661 po_number.send_keys(ntefield)662 end663 def cancel()664 wait = Selenium::WebDriver::Wait.new(:timeout => 5)665 wait.until {@driver.find_element(CANCEL_BTN).displayed?}666 cancel_popup = @driver.find_element(CANCEL_BTN)667 cancel_popup.click668 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)669 wait2.until {@driver.find_element(TOP_PONUMBER).displayed?}670 end671 def actions()672 #Use actions_(action) methods from here673 wait = Selenium::WebDriver::Wait.new(:timeout => 5)674 wait.until {@driver.find_element(ACTIONS_BTN).displayed?}675 actions_popup = @driver.find_element(ACTIONS_BTN)676 actions_popup.click677 end678 def save()679 wait = Selenium::WebDriver::Wait.new(:timeout => 5)680 wait.until {@driver.find_element(SAVE_BTN).displayed?}681 save = @driver.find_element(SAVE_BTN)682 save.click683 end684 def save_close()685 wait = Selenium::WebDriver::Wait.new(:timeout => 5)686 wait.until {@driver.find_element(SAVE_AND_CLOSE_BTN).displayed?}687 save_and_close = @driver.find_element(SAVE_AND_CLOSE_BTN)688 save_and_close.click689 @driver.switch_to.default_content690 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)691 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}692 end693 #CSS Methods: Popup (Lines)694 def lines_tab()695 wait = Selenium::WebDriver::Wait.new(:timeout => 5)696 wait.until {@driver.find_element(LINES_TAB).displayed?}697 lines_tab = @driver.find_element(LINES_TAB)698 lines_tab.click699 end700 def line1_service_date(servicedate1)701 wait = Selenium::WebDriver::Wait.new(:timeout => 5)702 wait.until {@driver.find_element(LINE1_SERVICE_DATE_SPAN).displayed?}703 span_field = @driver.find_element(LINE1_SERVICE_DATE_SPAN)704 span_field.click705 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)706 wait2.until {@driver.find_element(LINE1_SERVICE_DATE).displayed?}707 servicedate_field = @driver.find_element(LINE1_SERVICE_DATE)708 servicedate_field.send_keys(servicedate1)709 end710 def line1_item(item1)711 wait = Selenium::WebDriver::Wait.new(:timeout => 5)712 wait.until {@driver.find_element(LINE1_ITEM_SPAN).displayed?}713 span_field = @driver.find_element(LINE1_ITEM_SPAN)714 span_field.click715 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)716 wait2.until {@driver.find_element(LINE1_ITEM).displayed?}717 item_field = @driver.find_element(LINE1_ITEM)718 item_field.send_keys(item1)719 sleep(1)720 @driver.action.send_keys(:enter).perform721 sleep(1)722 end723 def line1_description(description1)724 wait = Selenium::WebDriver::Wait.new(:timeout => 5)725 wait.until {@driver.find_element(LINE1_DESCRIPTION).displayed?}726 span_field = @driver.find_element(LINE1_DESCRIPTION)727 span_field.click728 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)729 wait2.until {@driver.find_element(LINE1_DESCRIPTION_TEXTAREA).displayed?}730 item_field = @driver.find_element(LINE1_DESCRIPTION_TEXTAREA)731 item_field.send_keys(description1)732 sleep(1)733 @driver.action.send_keys(:enter).perform734 sleep(1)735 end736 def line1_quantity(quantity1)737 wait = Selenium::WebDriver::Wait.new(:timeout => 5)738 wait.until {@driver.find_element(LINE1_QUANTITY_SPAN).displayed?}739 span_field = @driver.find_element(LINE1_QUANTITY_SPAN)740 span_field.click741 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)742 wait2.until {@driver.find_element(LINE1_QUANTITY).displayed?}743 item_field = @driver.find_element(LINE1_QUANTITY)744 @driver.action.double_click(item_field).perform745 @driver.action.send_keys(:backspace)746 item_field.send_keys(quantity1)747 sleep(1)748 @driver.action.send_keys(:tab).perform749 sleep(1)750 end751 def line1_total(total1)752 wait = Selenium::WebDriver::Wait.new(:timeout => 5)753 wait.until {@driver.find_element(LINE1_TOTAL_SPAN).displayed?}754 span_total = @driver.find_element(LINE1_TOTAL_SPAN)755 span_total.click756 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)757 wait2.until {@driver.find_element(LINE1_TOTAL).displayed?}758 total = @driver.find_element(LINE1_TOTAL)759 total.send_keys(total1)760 end761 def line1_gettotal762 total = @driver.find_element(LINE1_TOTAL_SPAN).text.to_f763 end764 def line1_delete()765 wait = Selenium::WebDriver::Wait.new(:timeout => 5)766 wait.until {@driver.find_element(LINE1_DELETE).displayed?}767 trashcan = @driver.find_element(LINE1_DELETE)768 trashcan.click769 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)770 wait2.until {@driver.find_element(AJAX).displayed? == false}771 sleep(2)772 end773 def line2_service_date(servicedate2)774 wait = Selenium::WebDriver::Wait.new(:timeout => 5)775 wait.until {@driver.find_element(LINE2_SERVICE_DATE_SPAN).displayed?}776 span_field = @driver.find_element(LINE2_SERVICE_DATE_SPAN)777 span_field.click778 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)779 wait2.until {@driver.find_element(LINE2_SERVICE_DATE).displayed?}780 servicedate_field = @driver.find_element(LINE2_SERVICE_DATE)781 servicedate_field.send_keys(servicedate2)782 end783 def line2_item(item2)784 wait = Selenium::WebDriver::Wait.new(:timeout => 5)785 wait.until {@driver.find_element(LINE2_ITEM_SPAN).displayed?}786 span_field = @driver.find_element(LINE2_ITEM_SPAN)787 span_field.click788 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)789 wait2.until {@driver.find_element(LINE2_ITEM).displayed?}790 item_field = @driver.find_element(LINE2_ITEM)791 item_field.send_keys(item2)792 sleep(1)793 @driver.action.send_keys(:enter).perform794 sleep(1)795 end796 def line2_description(description2)797 wait = Selenium::WebDriver::Wait.new(:timeout => 5)798 wait.until {@driver.find_element(LINE2_DESCRIPTION).displayed?}799 span_field = @driver.find_element(LINE2_DESCRIPTION)800 span_field.click801 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)802 wait2.until {@driver.find_element(LINE2_DESCRIPTION_TEXTAREA).displayed?}803 item_field = @driver.find_element(LINE2_DESCRIPTION_TEXTAREA)804 item_field.send_keys(description2)805 sleep(1)806 @driver.action.send_keys(:enter).perform807 sleep(1)808 end809 def line2_quantity(quantity2)810 wait = Selenium::WebDriver::Wait.new(:timeout => 5)811 wait.until {@driver.find_element(LINE2_QUANTITY_SPAN).displayed?}812 span_field = @driver.find_element(LINE2_QUANTITY_SPAN)813 span_field.click814 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)815 wait2.until {@driver.find_element(LINE2_QUANTITY).displayed?}816 item_field = @driver.find_element(LINE2_QUANTITY)817 @driver.action.double_click(item_field).perform818 @driver.action.send_keys(:backspace)819 item_field.send_keys(quantity2)820 sleep(1)821 @driver.action.send_keys(:tab).perform822 sleep(1)823 end824 def line2_total(total2)825 wait = Selenium::WebDriver::Wait.new(:timeout => 5)826 wait.until {@driver.find_element(LINE2_TOTAL_SPAN).displayed?}827 span_total = @driver.find_element(LINE2_TOTAL_SPAN)828 span_total.click829 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)830 wait2.until {@driver.find_element(LINE2_TOTAL).displayed?}831 total = @driver.find_element(LINE2_TOTAL)832 total.send_keys(total2)833 end834 def line2_gettotal835 total = @driver.find_element(LINE2_TOTAL_SPAN).text.to_f836 end837 def line2_delete()838 wait = Selenium::WebDriver::Wait.new(:timeout => 5)839 wait.until {@driver.find_element(LINE2_DELETE).displayed?}840 trashcan = @driver.find_element(LINE2_DELETE)841 trashcan.click842 end843 def line3_service_date(servicedate3)844 wait = Selenium::WebDriver::Wait.new(:timeout => 5)845 wait.until {@driver.find_element(LINE3_SERVICE_DATE_SPAN).displayed?}846 span_field = @driver.find_element(LINE3_SERVICE_DATE_SPAN)847 span_field.click848 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)849 wait2.until {@driver.find_element(LINE3_SERVICE_DATE).displayed?}850 servicedate_field = @driver.find_element(LINE3_SERVICE_DATE)851 servicedate_field.send_keys(servicedate3)852 end853 def line3_item(item3)854 wait = Selenium::WebDriver::Wait.new(:timeout => 5)855 wait.until {@driver.find_element(LINE3_ITEM_SPAN).displayed?}856 span_field = @driver.find_element(LINE3_ITEM_SPAN)857 span_field.click858 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)859 wait2.until {@driver.find_element(LINE3_ITEM).displayed?}860 item_field = @driver.find_element(LINE3_ITEM)861 item_field.send_keys(item3)862 sleep(1)863 @driver.action.send_keys(:enter).perform864 sleep(1)865 end866 def line3_description(description3)867 wait = Selenium::WebDriver::Wait.new(:timeout => 5)868 wait.until {@driver.find_element(LINE3_DESCRIPTION).displayed?}869 span_field = @driver.find_element(LINE3_DESCRIPTION)870 span_field.click871 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)872 wait2.until {@driver.find_element(LINE3_DESCRIPTION_TEXTAREA).displayed?}873 item_field = @driver.find_element(LINE3_DESCRIPTION_TEXTAREA)874 item_field.send_keys(description3)875 sleep(1)876 @driver.action.send_keys(:enter).perform877 sleep(1)878 end879 def line3_quantity(quantity3)880 wait = Selenium::WebDriver::Wait.new(:timeout => 5)881 wait.until {@driver.find_element(LINE3_QUANTITY_SPAN).displayed?}882 span_field = @driver.find_element(LINE3_QUANTITY_SPAN)883 span_field.click884 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)885 wait2.until {@driver.find_element(LINE3_QUANTITY).displayed?}886 item_field = @driver.find_element(LINE3_QUANTITY)887 @driver.action.double_click(item_field).perform888 @driver.action.send_keys(:backspace)889 item_field.send_keys(quantity3)890 sleep(1)891 @driver.action.send_keys(:tab).perform892 sleep(1)893 end894 def line3_total(total3)895 wait = Selenium::WebDriver::Wait.new(:timeout => 5)896 wait.until {@driver.find_element(LINE3_TOTAL_SPAN).displayed?}897 span_total = @driver.find_element(LINE3_TOTAL_SPAN)898 span_total.click899 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)900 wait2.until {@driver.find_element(LINE3_TOTAL).displayed?}901 total = @driver.find_element(LINE3_TOTAL)902 total.send_keys(total3)903 end904 def line3_gettotal905 total = @driver.find_element(LINE3_TOTAL_SPAN).text.to_f906 end907 def line3_delete()908 wait = Selenium::WebDriver::Wait.new(:timeout => 5)909 wait.until {@driver.find_element(LINE3_DELETE).displayed?}910 trashcan = @driver.find_element(LINE3_DELETE)911 trashcan.click912 end913 def add_lines()914 wait = Selenium::WebDriver::Wait.new(:timeout => 5)915 wait.until {@driver.find_element(ADD_LINES).displayed?}916 @driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")917 button = @driver.find_element(ADD_LINES)918 button.click919 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)920 wait2.until {@driver.find_element(AJAX).displayed? == false}921 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)922 wait3.until {@driver.find_element(NEW_LINE_VERIFY).displayed?}923 sleep(1)924 end925 def clear_lines()926 wait = Selenium::WebDriver::Wait.new(:timeout => 5)927 wait.until {@driver.find_element(CLEAR_LINES).displayed?}928 @driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")929 button = @driver.find_element(CLEAR_LINES)930 button.click931 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)932 wait2.until {@driver.find_element(AJAX).displayed? == false}933 #wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)934 #wait3.until {@driver.find_element(LINE1_DESCRIPTION).displayed?}935 #wait4 = Selenium::WebDriver::Wait.new(:timeout => 5)936 #wait4.until {@driver.find_element(LINE1_DESCRIPTION)['value'] == nil}937 sleep(1) #This button has nothing for me to use to wait for.938 end939 def subtotal()940 subtotal = @driver.find_element(SUBTOTAL).text.gsub(/[$,]/,'').to_f941 end942 def select_tax(taxcode)943 dropdown_list = @driver.find_element(TAX_DROPDOWN)944 options = dropdown_list.find_elements(tag_name: 'option')945 options.each {|option| option.click if option.text == (taxcode)}946 end947 def taxtotal()948 taxtotal = @driver.find_element(TAXTOTAL).value.to_f949 end950 def total()951 total = @driver.find_element(TOTAL).text952 end953 #CSS Methods: Popup (Scheduling)954 def scheduling_tab()955 wait = Selenium::WebDriver::Wait.new(:timeout => 5)956 wait.until {@driver.find_element(SCHEDULING_TAB).displayed?}957 scheduling_tab = @driver.find_element(SCHEDULING_TAB)958 scheduling_tab.click959 end960 def job_cancel(jobcancel)961 wait = Selenium::WebDriver::Wait.new(:timeout => 5)962 wait.until {@driver.find_element(JOB_CANCELED_FIELD).displayed?}963 jobcanceled_field = @driver.find_element(JOB_CANCELED_FIELD)964 jobcanceled_field.send_keys(jobcancel)965 end966 def job_hold(jobhold)967 wait = Selenium::WebDriver::Wait.new(:timeout => 5)968 wait.until {@driver.find_element(JOB_HOLD_FIELD).displayed?}969 jobhold_field = @driver.find_element(JOB_HOLD_FIELD)970 jobhold_field.send_keys(jobhold)971 end972 def job_complete(jobcomplete)973 wait = Selenium::WebDriver::Wait.new(:timeout => 5)974 wait.until {@driver.find_element(JOB_COMPLETED_FIELD).displayed?}975 jobcompleted_field = @driver.find_element(JOB_COMPLETED_FIELD)976 jobcompleted_field.send_keys(jobcomplete)977 end978 def new_trip()979 wait = Selenium::WebDriver::Wait.new(:timeout => 5)980 wait.until {@driver.find_element(NEW_TRIP_BTN).displayed?}981 new_trip = @driver.find_element(NEW_TRIP_BTN)982 new_trip.click983 end984 def trip1_crew(trip1crew)985 dropdown_list = @driver.find_element(TRIP1_CREW)986 options = dropdown_list.find_elements(tag_name: 'option')987 options.each {|option| option.click if option.text == (locationselect)}988 end989 def trip1_schedulestart(trip1schedulestart)990 wait = Selenium::WebDriver::Wait.new(:timeout => 5)991 wait.until {@driver.find_element(TRIP1_SCHEDULED_START).displayed?}992 trip_field = @driver.find_element(TRIP1_SCHEDULED_START)993 trip_field.send_keys(trip1schedulestart)994 end995 def trip1_schedulefinish(trip1schedulefinish)996 wait = Selenium::WebDriver::Wait.new(:timeout => 5)997 wait.until {@driver.find_element(TRIP1_SCHEDULED_FINISH).displayed?}998 trip_field = @driver.find_element(TRIP1_SCHEDULED_FINISH)999 trip_field.send_keys(trip1schedulefinish)1000 end1001 def trip1_start(trip1start)1002 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1003 wait.until {@driver.find_element(TRIP1_START).displayed?}1004 trip_field = @driver.find_element(TRIP1_START)1005 trip_field.send_keys(trip1start)1006 end1007 def trip1_finish(trip1finish)1008 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1009 wait.until {@driver.find_element(TRIP1_FINISH).displayed?}1010 trip_field = @driver.find_element(TRIP1_FINISH)1011 trip_field.send_keys(trip1finish)1012 end1013 def trip2_crew(trip2crew)1014 dropdown_list = @driver.find_element(TRIP2_CREW)1015 options = dropdown_list.find_elements(tag_name: 'option')1016 options.each {|option| option.click if option.text == (locationselect)}1017 end1018 def trip2_schedulestart(trip2schedulestart)1019 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1020 wait.until {@driver.find_element(TRIP2_SCHEDULED_START).displayed?}1021 trip_field = @driver.find_element(TRIP2_SCHEDULED_START)1022 trip_field.send_keys(trip2schedulestart)1023 end1024 def trip2_schedulefinish(trip2schedulefinish)1025 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1026 wait.until {@driver.find_element(TRIP2_SCHEDULED_FINISH).displayed?}1027 trip_field = @driver.find_element(TRIP2_SCHEDULED_FINISH)1028 trip_field.send_keys(trip2schedulefinish)1029 end1030 def trip2_start(trip2start)1031 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1032 wait.until {@driver.find_element(TRIP2_START).displayed?}1033 trip_field = @driver.find_element(TRIP2_START)1034 trip_field.send_keys(trip2start)1035 end1036 def trip2_finish(trip2finish)1037 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1038 wait.until {@driver.find_element(TRIP2_FINISH).displayed?}1039 trip_field = @driver.find_element(TRIP2_FINISH)1040 trip_field.send_keys(trip2finish)1041 end1042 def trip3_crew(trip3crew)1043 dropdown_list = @driver.find_element(TRIP3_CREW)1044 options = dropdown_list.find_elements(tag_name: 'option')1045 options.each {|option| option.click if option.text == (locationselect)}1046 end1047 def trip3_schedulestart(trip3schedulestart)1048 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1049 wait.until {@driver.find_element(TRIP3_SCHEDULED_START).displayed?}1050 trip_field = @driver.find_element(TRIP3_SCHEDULED_START)1051 trip_field.send_keys(trip3schedulestart)1052 end1053 def trip3_schedulefinish(trip3schedulefinish)1054 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1055 wait.until {@driver.find_element(TRIP3_SCHEDULED_FINISH).displayed?}1056 trip_field = @driver.find_element(TRIP3_SCHEDULED_FINISH)1057 trip_field.send_keys(trip3schedulefinish)1058 end1059 def trip3_start(trip3start)1060 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1061 wait.until {@driver.find_element(TRIP3_START).displayed?}1062 trip_field = @driver.find_element(TRIP3_START)1063 trip_field.send_keys(trip3start)1064 end1065 def trip3_finish(trip3finish)1066 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1067 wait.until {@driver.find_element(TRIP3_FINISH).displayed?}1068 trip_field = @driver.find_element(TRIP3_FINISH)1069 trip_field.send_keys(trip3finish)1070 end1071 def delete_trip1()1072 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1073 wait.until {@driver.find_element(DELETE_TOP_TRIP).displayed?}1074 delete_trip = @driver.find_element(DELETE_TOP_TRIP)1075 delete_trip.click1076 end1077 #CSS Methods: Popup (Contacts)1078 def contacts_tab()1079 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1080 wait.until {@driver.find_element(CUSTOMER_CONTACTS_TAB).displayed?}1081 contacts_tab = @driver.find_element(CUSTOMER_CONTACTS_TAB)1082 contacts_tab.click1083 end1084 #Use Class - Contacts Resource from here1085 #CSS Methods: Popup (Notes)1086 def notes_tab()1087 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1088 wait.until {@driver.find_element(NOTES_TAB).displayed?}1089 notes_tab = @driver.find_element(NOTES_TAB)1090 notes_tab.click1091 end1092 def scope_of_work(scopeofwork)1093 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1094 wait.until {@driver.find_element(SCOPE_OF_WORK_FIELD).displayed?}1095 scope_of_work = @driver.find_element(SCOPE_OF_WORK_FIELD)1096 scope_of_work.send_keys(scopeofwork)1097 end1098 def additional_notes(additionalnotes)1099 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1100 wait.until {@driver.find_element(ADDITIONAL_NOTES_FIELD).displayed?}1101 additional_notes = @driver.find_element(ADDITIONAL_NOTES_FIELD)1102 additional_notes.send_keys(additionalnotes)1103 end1104 def special_instructions(specialinstructions)1105 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1106 wait.until {@driver.find_element(SPECIAL_INSTRUCTIONS_FIELD).displayed?}1107 special_instructions = @driver.find_element(SPECIAL_INSTRUCTIONS_FIELD)1108 special_instructions.send_keys(specialinstructions)1109 end1110 def private_notes(privatenotes)1111 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1112 wait.until {@driver.find_element(PRIVATE_NOTES_FIELD).displayed?}1113 private_notes = @driver.find_element(PRIVATE_NOTES_FIELD)1114 private_notes.send_keys(privatenotes)1115 end1116 #CSS Methods: Popup (Activities)1117 def activities_tab()1118 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1119 wait.until {@driver.find_element(ACTIVITIES_TAB).displayed?}1120 activities_tab = @driver.find_element(ACTIVITIES_TAB)1121 activities_tab.click1122 end1123 def search_activity(searchactivity)1124 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1125 wait.until {@driver.find_element(SEARCH_ACTIVITY).displayed?}1126 activity_search = @driver.find_element(SEARCH_ACTIVITY)1127 activity_search.send_keys(searchactivity)1128 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)1129 wait2.until {@driver.find_element(JOB_ACTIVITY_SEARCH_BTN).displayed?}1130 search_confirm = @driver.find_element(JOB_ACTIVITY_SEARCH_BTN)1131 search_confirm.click1132 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)1133 wait3.until {@driver.find_element(TOP_ACTIVITY_DESCRIPTION).downcase.include?(searchactivity.downcase)}1134 end1135 def top_activity()1136 i = 01137 loopcount = 51138 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1139 wait.until {@driver.find_element(TOP_ACTIVITY).displayed?}1140 top_refnumber = @driver.find_element(TOP_ACTIVITY)1141 top_refnumber.click1142 loop do1143 i += 11144 @driver.switch_to.frame(0)1145 begin1146 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)1147 wait2.until {@driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed?}1148 rescue Selenium::WebDriver::Error::TimeoutError1149 false1150 end1151 if1152 begin1153 @driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed? == true1154 rescue Selenium::WebDriver::Error::NoSuchElementError1155 false1156 end1157 break1158 end1159 if i == loopcount1160 raise FrameError1161 end1162 end1163 end1164 def top_activitydescription()1165 top_activitydescription = @driver.find_element(TOP_ACTIVITY_DESCRIPTION)1166 end1167 #CSS Methods: Popup (Invoices)1168 def invoices_tab()1169 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1170 wait.until {@driver.find_element(INVOICES_TAB).displayed?}1171 invoices_tab = @driver.find_element(INVOICES_TAB)1172 invoices_tab.click1173 end1174 def search_invoice(searchinvoice)1175 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1176 wait.until {@driver.find_element(SEARCH_INVOICE).displayed?}1177 invoice_search = @driver.find_element(SEARCH_INVOICE)1178 invoice_search.send_keys(searchinvoice)1179 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)1180 wait2.until {@driver.find_element(JOB_INVOICE_SEARCH_BTN).displayed?}1181 search_confirm = @driver.find_element(JOB_INVOICE_SEARCH_BTN)1182 search_confirm.click1183 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)1184 wait.until {@driver.find_element(TOP_INVOICE).text.include?(searchinvoice)}1185 end1186 def top_invoice()1187 i = 01188 loopcount = 51189 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1190 wait.until {@driver.find_element(TOP_INVOICE).displayed?}1191 top_refnumber = @driver.find_element(TOP_INVOICE)1192 top_refnumber.click1193 loop do1194 i += 11195 @driver.switch_to.frame(0)1196 begin1197 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)1198 wait2.until {@driver.find_element(INVOICE_PONUMBER_FIELD).displayed?}1199 rescue Selenium::WebDriver::Error::TimeoutError1200 false1201 end1202 if1203 begin1204 @driver.find_element(INVOICE_PONUMBER_FIELD).displayed? == true1205 rescue Selenium::WebDriver::Error::NoSuchElementError1206 false1207 end1208 break1209 end1210 if i == loopcount1211 raise FrameError1212 end1213 end1214 end1215 #CSS Methods: Popup (Deposits)1216 def deposits_tab()1217 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1218 wait.until {@driver.find_element(DEPOSITS_TAB).displayed?}1219 deposits_tab = @driver.find_element(DEPOSITS_TAB)1220 deposits_tab.click1221 end1222 def search_deposit(searchdeposit)1223 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1224 wait.until {@driver.find_element(SEARCH_DEPOSIT).displayed?}1225 deposit_search = @driver.find_element(SEARCH_DEPOSIT)1226 deposit_search.send_keys(searchdeposit)1227 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)1228 wait2.until {@driver.find_element(JOB_DEPOSIT_SEARCH_BTN).displayed?}1229 search_confirm = @driver.find_element(JOB_DEPOSIT_SEARCH_BTN)1230 search_confirm.click1231 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)1232 wait3.until {@driver.find_element(TOP_DEPOSIT).text.include?(searchdeposit)}1233 end1234 def top_deposit()1235 i = 01236 loopcount = 51237 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1238 wait.until {@driver.find_element(TOP_DEPOSIT).displayed?}1239 top_refnumber = @driver.find_element(TOP_DEPOSIT)1240 top_refnumber.click...
Class - Customers Resource.rb
Source:Class - Customers Resource.rb
...503 def search_customer(searchname)504 wait = Selenium::WebDriver::Wait.new(:timeout => 5)505 wait.until {@driver.find_element(SEARCH_FIELD).displayed?}506 customer_search = @driver.find_element(SEARCH_FIELD)507 customer_search.send_keys(searchname)508 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)509 wait2.until {@driver.find_element(SEARCH_BTN).displayed?}510 search_confirm = @driver.find_element(SEARCH_BTN)511 search_confirm.click512 wait3 = Selenium::WebDriver::Wait.new(:timeout => 10)513 wait3.until {@driver.find_element(TOP_CUSTOMER).text.downcase.include?(searchname.downcase)}514 end515 def search_customerid(searchname)516 i = 0517 loopcount = 5518 loop do519 wait = Selenium::WebDriver::Wait.new(:timeout => 5)520 if521 begin522 wait.until {@driver.find_element(ID_COLUMN).displayed?} == true523 rescue Selenium::WebDriver::Error::StaleElementReferenceError524 false525 end526 break527 if i == loopcount528 raise StaleError529 end530 end531 end532 customer_search = @driver.find_element(ID_COLUMN)533 customer_search.send_keys(searchname)534 @driver.action.send_keys(:enter).perform535 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)536 wait2.until {@driver.find_element(TOP_REFNUMBER).text.include?(searchname)}537 end538 def search_customerid_field()539 field = @driver.find_element(ID_COLUMN)540 end541 def search_customername(searchname)542 i = 0543 loopcount = 5544 loop do545 wait = Selenium::WebDriver::Wait.new(:timeout => 5)546 if547 begin548 wait.until {@driver.find_element(NAME_COLUMN).displayed?} == true549 rescue Selenium::WebDriver::Error::StaleElementReferenceError550 false551 end552 break553 if i == loopcount554 raise StaleError555 end556 end557 end558 customer_search = @driver.find_element(NAME_COLUMN)559 customer_search.send_keys(searchname)560 @driver.action.send_keys(:enter).perform561 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)562 wait2.until {@driver.find_element(TOP_CUSTOMER).text.downcase.include?(searchname.downcase)}563 end564 def search_customername_field()565 field = @driver.find_element(NAME_COLUMN)566 end567 def search_reset()568 currentrecords = @driver.find_element(class: "Counter_Message").text569 wait = Selenium::WebDriver::Wait.new(:timeout => 5)570 wait.until {@driver.find_element(RESET_BTN).displayed?}571 search_reset = @driver.find_element(RESET_BTN)572 search_reset.click573 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)574 wait2.until {@driver.find_element(class: "Counter_Message").text != currentrecords}575 end576 def grid_options()577 wait = Selenium::WebDriver::Wait.new(:timeout => 5)578 wait.until {@driver.find_element(GRID_OPTIONS_DROPDOWN).displayed?}579 grid_options = @driver.find_element(GRID_OPTIONS_DROPDOWN)580 grid_options.click581 end582 def export_customers()583 wait = Selenium::WebDriver::Wait.new(:timeout => 5)584 wait.until {@driver.find_element(EXPORT_CUSTOMERS).displayed?}585 export_customers = @driver.find_element(EXPORT_CUSTOMERS)586 export_customers.click587 sleep(2)588 end589 def show_inactives()590 wait = Selenium::WebDriver::Wait.new(:timeout => 5)591 wait.until {@driver.find_element(SHOW_INACTIVES).displayed?}592 show_inactives = @driver.find_element(SHOW_INACTIVES)593 show_inactives.click594 end595 def grid_total()596 gridtotal = @driver.find_element(GRID_TOTAL)597 end598 def resource_performance()599 navigationStart = @driver.execute_script("return window.performance.timing.navigationStart")600 responseStart = @driver.execute_script("return window.performance.timing.responseStart")601 domComplete = @driver.execute_script("return window.performance.timing.domComplete")602 loadPerformance = domComplete - navigationStart603 wait = Selenium::WebDriver::Wait.new(:timeout => 20)604 wait.until {@driver.find_element(class: "Counter_Message").text != "0 records"}605 customers_records = @driver.find_element(class: "Counter_Message")606 customers_count = customers_records.text607 print "Customers: \n"608 print "%s \n" % customers_count609 print "Load Time: %s ms \n\n" % loadPerformance610 end611 #CSS Methods: Popup612 def name(customername)613 customer_name = @driver.find_element(NAME_FIELD)614 customer_name.send_keys(customername)615 end616 def dba_name(dbaname)617 dba_name = @driver.find_element(DBA_NAME_FIELD)618 dba_name.send_keys(dbaname)619 end620 def location(locationselect)621 dropdown_list = @driver.find_element(LOCATION_DROPDOWN)622 options = dropdown_list.find_elements(tag_name: 'option')623 options.each {|option| option.click if option.text == (locationselect)}624 end625 def time_zone(timezone)626 dropdown_list = @driver.find_element(TIME_ZONE_DROPDOWN)627 options = dropdown_list.find_elements(tag_name: 'option')628 options.each {|option| option.click if option.text == (timezone)}629 end630 def type(typeselect)631 dropdown_list = @driver.find_element(TYPE_DROPDOWN)632 options = dropdown_list.find_elements(tag_name: 'option')633 options.each {|option| option.click if option.text == (typeselect)}634 end635 def patrol_type(patroltype)636 dropdown_list = @driver.find_element(PATROL_TYPE_DROPDOWN)637 options = dropdown_list.find_elements(tag_name: 'option')638 options.each {|option| option.click if option.text == (patroltype)}639 end640 def stage(customerstage)641 dropdown_list = @driver.find_element(STAGE_DROPDOWN)642 options = dropdown_list.find_elements(tag_name: 'option')643 options.each {|option| option.click if option.text == (customerstage)}644 end645 def source(customersource)646 dropdown_list = @driver.find_element(SOURCE_DROPDOWN)647 options = dropdown_list.find_elements(tag_name: 'option')648 options.each {|option| option.click if option.text == (customersource)}649 end650 def phone(customerphone)651 customer_phone = @driver.find_element(PHONE_FIELD)652 customer_phone.send_keys(customerphone)653 end654 def email(customeremail)655 customer_email = @driver.find_element(EMAIL_FIELD)656 customer_email.send_keys(customeremail)657 end658 def website(customerwebsite)659 customer_website = @driver.find_element(WEBSITE_FIELD)660 customer_website.send_keys(customerwebsite)661 end662 def po_number(ponumber)663 po_number = @driver.find_element(PONUMBER_FIELD)664 po_number.send_keys(ponumber)665 end666 def account_executive(accountexecutive)667 dropdown_list = @driver.find_element(ACCOUNT_EXECUTIVE_DROPDOWN)668 options = dropdown_list.find_elements(tag_name: 'option')669 options.each {|option| option.click if option.text == (accountexecutive)}670 end671 def special_instructions(specialinstructions)672 special_instructions = @driver.find_element(SPECIAL_INSTRUCTIONS_FIELD)673 special_instructions.send_keys(specialinstructions)674 end675 def patrol_instructions(patrolinstructions)676 patrol_instructions = @driver.find_element(PATROL_INSTRUCTIONS_FIELD)677 patrol_instructions.send_keys(patrolinstructions)678 end679 def price_agreement(priceagreement)680 price_agreement = @driver.find_element(PRICE_AGREEMENT_FIELD)681 price_agreement.send_keys(priceagreement)682 end683 def is_subcustomer()684 wait = Selenium::WebDriver::Wait.new(:timeout => 5)685 wait.until {@driver.find_element(IS_SUBCUSTOMER_CHECKBOX).displayed?}686 checkbox = @driver.find_element(IS_SUBCUSTOMER_CHECKBOX)687 checkbos.click688 end689 def do_not_service()690 wait = Selenium::WebDriver::Wait.new(:timeout => 5)691 wait.until {@driver.find_element(DO_NOT_SERVICE_CHECKBOX).displayed?}692 checkbox = @driver.find_element(DO_NOT_SERVICE_CHECKBOX)693 checkbos.click694 end695 def under_contract()696 wait = Selenium::WebDriver::Wait.new(:timeout => 5)697 wait.until {@driver.find_element(UNDER_CONTRACT_CHECKBOX).displayed?}698 checkbox = @driver.find_element(UNDER_CONTRACT_CHECKBOX)699 checkbos.click700 end701 def cancel()702 wait = Selenium::WebDriver::Wait.new(:timeout => 5)703 wait.until {@driver.find_element(CANCEL_BTN).displayed?}704 cancel_popup = @driver.find_element(CANCEL_BTN)705 cancel_popup.click706 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)707 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}708 end709 def actions()710 #Use actions_(action) methods from here711 wait = Selenium::WebDriver::Wait.new(:timeout => 5)712 wait.until {@driver.find_element(ACTIONS_BTN).displayed?}713 actions_popup = @driver.find_element(ACTIONS_BTN)714 actions_popup.click715 end716 def save()717 wait = Selenium::WebDriver::Wait.new(:timeout => 5)718 wait.until {@driver.find_element(SAVE_BTN).enabled?}719 save = @driver.find_element(SAVE_BTN)720 save.click721 end722 def save_close()723 def wait_for()724 Selenium::WebDriver::Wait.new(:timeout => 5).until {yield}725 end726 wait_for {@driver.find_element(SAVE_AND_CLOSE_BTN).enabled?}727 save_and_close = @driver.find_element(SAVE_AND_CLOSE_BTN)728 save_and_close.click729 @driver.switch_to.default_content730 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)731 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}732 end733 #Class Modifiers: Popup (Contact Info Tab)734 def contact_info_tab()735 tab_name = @driver.find_element(CONTACT_INFO_TAB)736 tab_name.click737 end738 def bill_name(billname)739 input_field = @driver.find_element(BILL_NAME)740 input_field.send_keys(billname)741 end742 def bill_street(billstreet)743 input_field = @driver.find_element(BILL_STREET)744 input_field.send_keys(billstreet)745 end746 def bill_city(billcity)747 input_field = @driver.find_element(BILL_CITY)748 input_field.send_keys(billcity)749 end750 def bill_state(billstate)751 input_field = @driver.find_element(BILL_STATE)752 input_field.send_keys(billstate)753 end754 def bill_zip(billzip)755 input_field = @driver.find_element(BILL_ZIP)756 input_field.send_keys(billzip)757 end758 def bill_country(billcountry)759 input_field = @driver.find_element(BILL_COUNTRY)760 input_field.send_keys(billcountry)761 end762 def bill_contact(billcontact)763 input_field = @driver.find_element(BILL_CONTACT)764 input_field.send_keys(billcontact)765 sleep(1)766 driver.action.send_keys(:enter).perform767 sleep(1)768 end769 def site_name(sitename)770 input_field = @driver.find_element(SITE_NAME)771 input_field.send_keys(sitename)772 end773 #Used in databuffer wait action774 def site_name_verify()775 input_field = @driver.find_element(SITE_NAME)776 end777 def site_street(sitestreet)778 input_field = @driver.find_element(SITE_STREET)779 input_field.send_keys(sitestreet)780 end781 def site_city(sitecity)782 input_field = @driver.find_element(SITE_CITY)783 input_field.send_keys(sitecity)784 end785 def site_state(sitestate)786 input_field = @driver.find_element(SITE_STATE)787 input_field.send_keys(sitestate)788 end789 def site_zip(sitezip)790 input_field = @driver.find_element(SITE_ZIP)791 input_field.send_keys(sitezip)792 end793 def site_country(sitecountry)794 input_field = @driver.find_element(SITE_COUNTRY)795 input_field.send_keys(sitecountry)796 end797 def site_contact(sitecontact)798 input_field = @driver.find_element(SITE_CONTACT)799 input_field.send_keys(sitecontact)800 sleep(1)801 driver.action.send_keys(:enter).perform802 sleep(1)803 end804 def copy_to_site()805 copy_option = @driver.find_element(COPY_TO_SITE_OPTN)806 copy_option.click807 end808 def copy_to_billing()809 copy_option = @driver.find_element(COPY_TO_BILLING_OPTN)810 copy_option.click811 end812 #CSS Methods: Popup (Billing and Tax Tab)813 def billing_tab()814 tab_name = @driver.find_element(BILLING_AND_TAX_TAB)815 tab_name.click816 end817 def payment(customerpayment)818 dropdown_list = @driver.find_element(PAYMENT_DROPDOWN)819 options = dropdown_list.find_elements(tag_name: 'option')820 options.each {|option| option.click if option.text == (customerpayment)}821 end822 def delivery(customerdelivery)823 dropdown_list = @driver.find_element(DELIVERY_DROPDOWN)824 options = dropdown_list.find_elements(tag_name: 'option')825 options.each {|option| option.click if option.text == (customerdelivery)}826 end827 def taxable()828 checkbox = @driver.find_element(TAXABLE_CHECKBOX)829 checkbox.click()830 end831 def default_tax(defaulttax)832 dropdown_list = @driver.find_element(DEFAULT_TAX_CODE_DROPDOWN)833 options = dropdown_list.find_elements(tag_name: 'option')834 options.each {|option| option.click if option.text == (defaulttax)}835 end836 def terms(customerterms)837 dropdown_list = @driver.find_element(TERMS_DROPDOWN)838 options = dropdown_list.find_elements(tag_name: 'option')839 options.each {|option| option.click if option.text == (customerterms)}840 end841 def nte(customernte)842 nte_field = @driver.find_element(NTE_FIELD)843 nte_field.send_keys(customernte)844 end845 def tax_exempt(customertaxexempt)846 nte_field = @driver.find_element(TAX_EXEMPT_CODE_FIELD)847 nte_field.send_keys(customertaxexempt)848 end849 #CSS Methods: Popup (Activities Tab)850 def activities_tab()851 wait = Selenium::WebDriver::Wait.new(:timeout => 5)852 wait.until {@driver.find_element(ACTIVITIES_TAB).displayed?}853 activities_tab = @driver.find_element(ACTIVITIES_TAB)854 activities_tab.click855 end856 def search_activity(searchactivity)857 wait = Selenium::WebDriver::Wait.new(:timeout => 5)858 wait.until {@driver.find_element(SEARCH_ACTIVITY).displayed?}859 activity_search = @driver.find_element(SEARCH_ACTIVITY)860 activity_search.send_keys(searchactivity)861 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)862 wait2.until {@driver.find_element(CUSTOMER_ACTIVITY_SEARCH_BTN).displayed?}863 search_confirm = @driver.find_element(CUSTOMER_ACTIVITY_SEARCH_BTN)864 search_confirm.click865 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)866 wait3.until {@driver.find_element(TOP_ACTIVITY_DESCRIPTION).downcase.include?(searchactivity.downcase)}867 end868 def top_activity()869 i = 0870 loopcount = 5871 wait = Selenium::WebDriver::Wait.new(:timeout => 5)872 wait.until {@driver.find_element(TOP_ACTIVITY).displayed?}873 top_refnumber = @driver.find_element(TOP_ACTIVITY)874 top_refnumber.click875 loop do876 i += 1877 @driver.switch_to.frame(0)878 begin879 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)880 wait2.until {@driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed?}881 rescue Selenium::WebDriver::Error::TimeOutError882 false883 end884 if885 begin886 @driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed? == true887 rescue Selenium::WebDriver::Error::NoSuchElementError888 false889 end890 break891 end892 if i == loopcount893 raise FrameError894 end895 end896 end897 def top_activitydescription()898 top_activitydescription = @driver.find_element(TOP_ACTIVITY_DESCRIPTION)899 end900 #CSS Methods: Popup (Patrols Tab)901 def patrols_tab()902 wait = Selenium::WebDriver::Wait.new(:timeout => 5)903 wait.until {@driver.find_element(PATROLS_TAB).displayed?}904 patrols_tab = @driver.find_element(PATROLS_TAB)905 patrols_tab.click906 end907 def search_patrol(searchpatrol)908 wait = Selenium::WebDriver::Wait.new(:timeout => 5)909 wait.until {@driver.find_element(SEARCH_PATROL).displayed?}910 patrol_search = @driver.find_element(SEARCH_PATROL)911 patrol_search.send_keys(searchpatrol)912 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)913 wait2.until {@driver.find_element(CUSTOMER_PATROL_SEARCH_BTN).displayed?}914 search_confirm = @driver.find_element(CUSTOMER_PATROL_SEARCH_BTN)915 search_confirm.click916 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)917 wait3.until {@driver.find_element(TOP_PATROL_NAME).downcase.include?(searchpatrol.downcase)}918 end919 def top_patrol()920 wait = Selenium::WebDriver::Wait.new(:timeout => 5)921 wait.until {@driver.find_element(TOP_PATROL_REFNUMBER).displayed?}922 top_refnumber = @driver.find_element(TOP_PATROL_REFNUMBER)923 top_refnumber.click924 loop do925 i += 1926 @driver.switch_to.frame(0)927 begin928 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)929 wait2.until {@driver.find_element(PATROL_NAME_FIELD).displayed?}930 rescue Selenium::WebDriver::Error::TimeOutError931 false932 end933 if934 begin935 @driver.find_element(PATROL_NAME_FIELD).displayed? == true936 rescue Selenium::WebDriver::Error::NoSuchElementError937 false938 end939 break940 end941 if i == loopcount942 raise FrameError943 end944 end945 end946 def top_patrolname()947 top_patrolname = @driver.find_element(TOP_PATROL_NAME)948 end949 #CSS Methods: Popup (Estimates Tab)950 def estimates_tab()951 wait = Selenium::WebDriver::Wait.new(:timeout => 5)952 wait.until {@driver.find_element(ESTIMATES_TAB).displayed?}953 estimates_tab = @driver.find_element(ESTIMATES_TAB)954 estimates_tab.click955 end956 def search_estimate(searchestimate)957 wait = Selenium::WebDriver::Wait.new(:timeout => 5)958 wait.until {@driver.find_element(SEARCH_ESTIMATE).displayed?}959 estimate_search = @driver.find_element(SEARCH_ESTIMATE)960 estimate_search.send_keys(searchestimate)961 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)962 wait2.until {@driver.find_element(CUSTOMER_ESTIMATE_SEARCH_BTN).displayed?}963 search_confirm = @driver.find_element(CUSTOMER_ESTIMATE_SEARCH_BTN)964 search_confirm.click965 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)966 wait3.until {@driver.find_element(TOP_ESTIMATE_NAME).downcase.include?(searchestimate.downcase)}967 end968 def top_estimate()969 i = 0970 loopcount = 5971 wait = Selenium::WebDriver::Wait.new(:timeout => 5)972 wait.until {@driver.find_element(TOP_ESTIMATE_REFNUMBER).displayed?}973 top_refnumber = @driver.find_element(TOP_ESTIMATE_REFNUMBER)974 top_refnumber.click975 loop do976 i += 1977 @driver.switch_to.frame(0)978 begin979 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)980 wait2.until {@driver.find_element(ESTIMATE_NAME_FIELD).displayed?}981 rescue Selenium::WebDriver::Error::TimeOutError982 false983 end984 if985 begin986 @driver.find_element(ESTIMATE_NAME_FIELD).displayed? == true987 rescue Selenium::WebDriver::Error::NoSuchElementError988 false989 end990 break991 end992 if i == loopcount993 raise FrameError994 end995 end996 end997 def top_estimatename()998 top_estimatename = @driver.find_element(TOP_ESTIMATE_NAME)999 end1000 #CSS Methods: Popup (Jobs Tab)1001 def jobs_tab()1002 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1003 wait.until {@driver.find_element(JOBS_TAB).displayed?}1004 jobs_tab = @driver.find_element(JOBS_TAB)1005 jobs_tab.click1006 end1007 def search_job(searchjob)1008 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1009 wait.until {@driver.find_element(SEARCH_JOB).displayed?}1010 job_search = @driver.find_element(SEARCH_JOB)1011 job_search.send_keys(searchjob)1012 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)1013 wait2.until {@driver.find_element(CUSTOMER_JOB_SEARCH_BTN).displayed?}1014 search_confirm = @driver.find_element(CUSTOMER_JOB_SEARCH_BTN)1015 search_confirm.click1016 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)1017 wait3.until {@driver.find_element(TOP_JOB_NAME).downcase.include?(searchjob.downcase)}1018 end1019 def top_job()1020 i = 01021 loopcount = 51022 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1023 wait.until {@driver.find_element(TOP_JOB_REFNUMBER).displayed?}1024 top_refnumber = @driver.find_element(TOP_JOB_REFNUMBER)1025 top_refnumber.click1026 loop do1027 i += 11028 @driver.switch_to.frame(0)1029 begin1030 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)1031 wait2.until {@driver.find_element(JOB_NAME_FIELD).displayed?}1032 rescue Selenium::WebDriver::Error::TimeOutError1033 false1034 end1035 if1036 begin1037 @driver.find_element(JOB_NAME_FIELD).displayed? == true1038 rescue Selenium::WebDriver::Error::NoSuchElementError1039 false1040 end1041 break1042 end1043 if i == loopcount1044 raise FrameError1045 end1046 end1047 end1048 def top_jobname()1049 top_jobname = @driver.find_element(TOP_JOB_NAME)1050 end1051 #CSS Methods: Popup (Invoices Tab)1052 def invoices_tab()1053 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1054 wait.until {@driver.find_element(INVOICES_TAB).displayed?}1055 invoices_tab = @driver.find_element(INVOICES_TAB)1056 invoices_tab.click1057 end1058 def search_invoice(searchinvoice)1059 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1060 wait.until {@driver.find_element(SEARCH_INVOICE).displayed?}1061 invoice_search = @driver.find_element(SEARCH_INVOICE)1062 invoice_search.send_keys(searchinvoice)1063 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)1064 wait2.until {@driver.find_element(SEARCH_BTN).displayed?}1065 search_confirm = @driver.find_element(SEARCH_BTN)1066 search_confirm.click1067 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)1068 wait3.until {@driver.find_element(TOP_INVOICE_JOB_NAME).downcase.include?(searchinvoice.downcase)}1069 end1070 def top_invoice()1071 i = 01072 loopcount = 51073 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1074 wait.until {@driver.find_element(TOP_INVOICE_REFNUMBER).displayed?}1075 top_refnumber = @driver.find_element(TOP_INVOICE_REFNUMBER)1076 top_refnumber.click1077 loop do1078 i += 11079 @driver.switch_to.frame(0)1080 begin1081 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)1082 wait2.until {@driver.find_element(INVOICE_PONUMBER_FIELD).displayed?}1083 rescue Selenium::WebDriver::Error::TimeOutError1084 false1085 end1086 if1087 begin1088 @driver.find_element(INVOICE_PONUMBER_FIELD).displayed? == true1089 rescue Selenium::WebDriver::Error::NoSuchElementError1090 false1091 end1092 break1093 end1094 if i == loopcount1095 raise FrameError1096 end1097 end1098 end1099 def top_invoicename()1100 top_invoicename = @driver.find_element(TOP_INVOICE_JOB_NAME)1101 end1102 #CSS Methods: Popup (Pricing Tab)1103 def pricing_tab()1104 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1105 wait.until {@driver.find_element(PRICING_TAB).displayed?}1106 pricing_tab = @driver.find_element(PRICING_TAB)1107 pricing_tab.click1108 end1109 def search_price(searchprice)1110 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1111 wait.until {@driver.find_element(SEARCH_PRICE).displayed?}1112 price_search = @driver.find_element(SEARCH_PRICE)1113 price_search.send_keys(searchprice)1114 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)1115 wait2.until {@driver.find_element(SEARCH_BTN).displayed?}1116 search_confirm = @driver.find_element(SEARCH_BTN)1117 search_confirm.click1118 end1119 def top_contractname()1120 top_contractname = @driver.find_element(TOP_CONTRACT_NAME)1121 end1122 #CSS Methods: Popup (Contracts Tab)1123 def contracts_tab()1124 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1125 wait.until {@driver.find_element(CONTRACTS_TAB).displayed?}1126 contracts_tab = @driver.find_element(CONTRACTS_TAB)1127 contracts_tab.click1128 end1129 def search_contract(searchcontract)1130 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1131 wait.until {@driver.find_element(SEARCH_CONTRACT).displayed?}1132 contract_search = @driver.find_element(SEARCH_CONTRACT)1133 contract_search.send_keys(searchcontract)1134 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)1135 wait2.until {@driver.find_element(SEARCH_BTN).displayed?}1136 search_confirm = @driver.find_element(SEARCH_BTN)1137 search_confirm.click1138 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)1139 wait3.until {@driver.find_element(TOP_CONTRACT_NAME).downcase.include?(searchcontract.downcase)}1140 end1141 def top_contractname()1142 top_contractname = @driver.find_element(TOP_CONTRACT_NAME)1143 end1144 #CSS Methods: Popup (Routes Tab)1145 def routes_tab()1146 wait = Selenium::WebDriver::Wait.new(:timeout => 5)1147 wait.until {@driver.find_element(ROUTES_TAB).displayed?}...
Class - Invoices Resource.rb
Source:Class - Invoices Resource.rb
...175 loopcount = 5176 f = 0177 frameloopcount = 10178 select_job = @driver.find_element(JOB_SEARCH_FIELD)179 select_job.send_keys(selectjob)180 sleep(1)181 @driver.action.send_keys(:enter).perform182 sleep(1)183 select_job_next = @driver.find_element(JOB_NEXT_BTN)184 select_job_next.click185 loop do186 i += 1187 loop do188 f += 1189 begin190 @driver.switch_to.default_content191 @driver.switch_to.frame(0)192 rescue Selenium::WebDriver::Error::NoSuchFrameError193 false194 end195 break196 if f == frameloopcount197 raise FrameError198 end199 end200 begin201 wait2 = Selenium::WebDriver::Wait.new(:timeout => 8)202 wait2.until {@driver.find_element(INVOICE_DATE_FIELD).displayed?}203 rescue Selenium::WebDriver::Error::TimeoutError204 false205 end206 if207 begin208 @driver.find_element(INVOICE_DATE_FIELD).displayed? == true209 rescue Selenium::WebDriver::Error::NoSuchElementError210 false211 end212 break213 end214 if i == loopcount215 raise FrameError216 end217 end218 end219 def select_jobdev(selectjob)220 i = 0221 loopcount = 5222 select_job = @driver.find_element(JOB_SEARCH_FIELD)223 select_job.send_keys(selectjob)224 sleep(1)225 @driver.action.send_keys(:enter).perform226 sleep(1)227 select_job_next = @driver.find_element(JOB_NEXT_BTN)228 select_job_next.click229 wait = Selenium::WebDriver::Wait.new(:timeout => 10)230 wait.until {@driver.find_element(FRAME).displayed?}231 loop do232 i += 1233 @driver.switch_to.frame(0)234 begin235 wait2 = Selenium::WebDriver::Wait.new(:timeout => 8)236 wait2.until {@driver.find_element(INVOICE_DATE_FIELD).displayed?}237 rescue Selenium::WebDriver::Error::TimeOutError238 false239 end240 if241 begin242 @driver.find_element(INVOICE_DATE_FIELD).displayed? == true243 rescue Selenium::WebDriver::Error::NoSuchElementError244 false245 end246 break247 end248 if i == loopcount249 raise FrameError250 end251 end252 end253 def top()254 top_record = @driver.find_element(TOP_INVOICE)255 end256 def top_jobname()257 top_record = @driver.find_element(TOP_JOBNAME)258 end259 def top_refnumber()260 top_refnumber = @driver.find_element(TOP_REFNUMBER)261 end262 def top_qbid()263 top_qbid = @driver.find_element(TOP_QBID)264 end265 def top_nsid()266 top_qbid = @driver.find_element(TOP_NSID)267 end268 def top_ponumber()269 top_ponumber = @driver.find_element(TOP_PONUMBER)270 end271 def top_open()272 i = 0273 loopcount = 5274 wait = Selenium::WebDriver::Wait.new(:timeout => 10)275 wait.until {@driver.find_element(TOP_REFNUMBER).displayed?}276 top_refnumber = @driver.find_element(TOP_REFNUMBER)277 top_refnumber.click278 loop do279 i += 1280 @driver.switch_to.frame(0)281 begin282 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)283 wait2.until {@driver.find_element(INVOICE_DATE_FIELD).displayed?}284 rescue Selenium::WebDriver::Error::TimeOutError285 false286 end287 if288 begin289 @driver.find_element(INVOICE_DATE_FIELD).displayed? == true290 rescue Selenium::WebDriver::Error::NoSuchElementError291 false292 end293 break294 end295 if i == loopcount296 raise FrameError297 end298 end299 end300 def top_actions()301 wait = Selenium::WebDriver::Wait.new(:timeout => 10)302 wait.until {@driver.find_element(TOP_INVOICE_ACTIONS).displayed?}303 top_actions = @driver.find_element(TOP_INVOICE_ACTIONS)304 top_actions.click305 end306 def actions_createactivity()307 i = 0308 loopcount = 5309 wait = Selenium::WebDriver::Wait.new(:timeout => 5)310 wait.until {@driver.find_element(ACTIONS_CREATEACTIVITY).displayed?}311 top_createactivity = @driver.find_element(ACTIONS_CREATEACTIVITY)312 top_createactivity.click313 loop do314 i += 1315 @driver.switch_to.frame(0)316 begin317 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)318 wait2.until {@driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed?}319 rescue Selenium::WebDriver::Error::TimeOutError320 false321 end322 if323 begin324 @driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed? == true325 rescue Selenium::WebDriver::Error::NoSuchElementError326 false327 end328 break329 end330 if i == loopcount331 raise FrameError332 end333 end334 end335 def actions_documents()336 i = 0337 loopcount = 5338 wait = Selenium::WebDriver::Wait.new(:timeout => 5)339 wait.until {@driver.find_element(ACTIONS_DOCUMENTS).displayed?}340 top_documents = @driver.find_element(ACTIONS_DOCUMENTS)341 top_documents.click342 loop do343 i += 1344 @driver.switch_to.frame(0)345 begin346 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)347 wait2.until {@driver.find_element(DOCUMENTS_SHOWHIDE_UPLOADER).displayed?}348 rescue Selenium::WebDriver::Error::TimeOutError349 false350 end351 if352 begin353 @driver.find_element(DOCUMENTS_SHOWHIDE_UPLOADER).displayed? == true354 rescue Selenium::WebDriver::Error::NoSuchElementError355 false356 end357 break358 end359 if i == loopcount360 raise FrameError361 end362 end363 end364 def actions_printemail()365 i = 0366 loopcount = 5367 wait = Selenium::WebDriver::Wait.new(:timeout => 5)368 wait.until {@driver.find_element(ACTIONS_PRINTEMAIL).displayed?}369 top_printemail = @driver.find_element(ACTIONS_PRINTEMAIL)370 top_printemail.click371 loop do372 i += 1373 @driver.switch_to.frame(0)374 begin375 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)376 wait2.until {@driver.find_element(PRINTEMAIL_PDF_CHECKBOX).displayed?}377 rescue Selenium::WebDriver::Error::TimeOutError378 false379 end380 if381 begin382 @driver.find_element(PRINTEMAIL_PDF_CHECKBOX).displayed? == true383 rescue Selenium::WebDriver::Error::NoSuchElementError384 false385 end386 break387 end388 if i == loopcount389 raise FrameError390 end391 end392 end393 def search_invoice(searchname)394 wait = Selenium::WebDriver::Wait.new(:timeout => 5)395 wait.until {@driver.find_element(SEARCH_FIELD).displayed?}396 job_search = @driver.find_element(SEARCH_FIELD)397 job_search.send_keys(searchname)398 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)399 wait2.until {@driver.find_element(SEARCH_BTN).displayed?}400 search_confirm = @driver.find_element(SEARCH_BTN)401 search_confirm.click402 wait3 = Selenium::WebDriver::Wait.new(:timeout => 10)403 wait3.until {@driver.find_element(TOP_JOBNAME).text.downcase.include?(searchname.downcase)}404 end405 def search_invoiceid(searchname)406 i = 0407 loopcount = 5408 loop do409 wait = Selenium::WebDriver::Wait.new(:timeout => 5)410 if411 begin412 wait.until {@driver.find_element(ID_COLUMN).displayed?} == true413 rescue Selenium::WebDriver::Error::StaleElementReferenceError414 false415 end416 break417 if i == loopcount418 raise StaleError419 end420 end421 end422 invoice_search = @driver.find_element(ID_COLUMN)423 invoice_search.send_keys(searchname)424 @driver.action.send_keys(:enter).perform425 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)426 wait2.until {@driver.find_element(TOP_REFNUMBER).text.include?(searchname)}427 end428 def search_invoiceid_field()429 field = @driver.find_element(ID_COLUMN)430 end431 def search_invoicename(searchname)432 i = 0433 loopcount = 5434 loop do435 wait = Selenium::WebDriver::Wait.new(:timeout => 5)436 if437 begin438 wait.until {@driver.find_element(NAME_COLUMN).displayed?} == true439 rescue Selenium::WebDriver::Error::StaleElementReferenceError440 false441 end442 break443 if i == loopcount444 raise StaleError445 end446 end447 end448 invoice_search = @driver.find_element(NAME_COLUMN)449 invoice_search.send_keys(searchname)450 @driver.action.send_keys(:enter).perform451 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)452 wait2.until {@driver.find_element(TOP_INVOICE).text.downcase.include?(searchname.downcase)}453 end454 def search_invoicename_field()455 field = @driver.find_element(NAME_COLUMN)456 end457 def search_reset()458 currentrecords = @driver.find_element(class: "Counter_Message").text459 wait = Selenium::WebDriver::Wait.new(:timeout => 5)460 wait.until {@driver.find_element(RESET_BTN).displayed?}461 search_reset = @driver.find_element(RESET_BTN)462 search_reset.click463 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)464 wait2.until {@driver.find_element(class: "Counter_Message").text != currentrecords}465 end466 def grid_options()467 wait = Selenium::WebDriver::Wait.new(:timeout => 5)468 wait.until {@driver.find_element(GRID_OPTIONS_DROPDOWN).displayed?}469 grid_options = @driver.find_element(GRID_OPTIONS_DROPDOWN)470 grid_options.click471 end472 def export_invoices()473 wait = Selenium::WebDriver::Wait.new(:timeout => 5)474 wait.until {@driver.find_element(EXPORT_INVOICES).displayed?}475 export_jobs = @driver.find_element(EXPORT_INVOICES)476 export_jobs.click477 sleep(2)478 end479 def show_inactives()480 wait = Selenium::WebDriver::Wait.new(:timeout => 5)481 wait.until {@driver.find_element(SHOW_INACTIVES).displayed?}482 show_inactives = @driver.find_element(SHOW_INACTIVES)483 show_inactives.click484 end485 def qbo_verify()486 wait = Selenium::WebDriver::Wait.new(:timeout => 10)487 wait.until {@driver.find_element(TOP_QBID).displayed?}488 qbid = @driver.find_element(TOP_QBID)489 qbid_display = qbid.text490 expect(qbid_display).not_to eq("")491 print "QBID: %s" % qbid_display492 end493 def ns_verify()494 wait = Selenium::WebDriver::Wait.new(:timeout => 10)495 wait.until {@driver.find_element(TOP_NSID).displayed?}496 nsid = @driver.find_element(TOP_NSID)497 nsid_display = nsid.text498 expect(qbid_display).not_to eq("")499 print "NS Invoice Number: %s" % nsid_display500 end501 def grid_total()502 gridtotal = @driver.find_element(GRID_TOTAL)503 end504 def resource_performance()505 navigationStart = @driver.execute_script("return window.performance.timing.navigationStart")506 responseStart = @driver.execute_script("return window.performance.timing.responseStart")507 domComplete = @driver.execute_script("return window.performance.timing.domComplete")508 loadPerformance = domComplete - navigationStart509 wait = Selenium::WebDriver::Wait.new(:timeout => 20)510 wait.until {@driver.find_element(GRID_TOTAL).text != "0 records"}511 invoices_records = @driver.find_element(GRID_TOTAL)512 invoices_count = invoices_records.text513 print "Invoices: \n"514 print "%s \n" % invoices_count515 print "Load Time: %s ms \n\n" % loadPerformance516 end517 #CSS Methods: Popup518 def invoice_date(invoicedate)519 wait = Selenium::WebDriver::Wait.new(:timeout => 10)520 wait.until {@driver.find_element(INVOICE_DATE_FIELD).displayed?}521 invoice_date = @driver.find_element(INVOICE_DATE_FIELD)522 invoice_date.send_keys(jobname)523 end524 def terms(termsselect)525 wait = Selenium::WebDriver::Wait.new(:timeout => 10)526 wait.until {@driver.find_element(TERMS_DROPDOWN).displayed?}527 dropdown_list = @driver.find_element(TERMS_DROPDOWN)528 options = dropdown_list.find_elements(tag_name: 'option')529 options.each {|option| option.click if option.text == (termsselect)}530 end531 def due_date(duedate)532 wait = Selenium::WebDriver::Wait.new(:timeout => 10)533 wait.until {@driver.find_element(DUE_DATE_FIELD).displayed?}534 duedate = @driver.find_element(DUE_DATE_FIELD)535 duedate.send_keys(duedate)536 end537 def location(locationselect)538 dropdown_list = @driver.find_element(LOCATION_DROPDOWN)539 options = dropdown_list.find_elements(tag_name: 'option')540 options.each {|option| option.click if option.text == (locationselect)}541 end542 def class(classselect)543 wait = Selenium::WebDriver::Wait.new(:timeout => 10)544 wait.until {@driver.find_element(CLASS_DROPDOWN).displayed?}545 dropdown_list = @driver.find_element(CLASS_DROPDOWN)546 options = dropdown_list.find_elements(tag_name: 'option')547 options.each {|option| option.click if option.text == (classselect)}548 end549 def line_business(lineofbusiness)550 wait = Selenium::WebDriver::Wait.new(:timeout => 10)551 wait.until {@driver.find_element(LINE_OF_BUSINESS_DROPDOWN).displayed?}552 dropdown_list = @driver.find_element(LINE_OF_BUSINESS_DROPDOWN)553 options = dropdown_list.find_elements(tag_name: 'option')554 options.each {|option| option.click if option.text == (lineofbusiness)}555 end556 def po_number(ponumber)557 wait = Selenium::WebDriver::Wait.new(:timeout => 10)558 wait.until {@driver.find_element(PONUMBER_FIELD).displayed?}559 po_number = @driver.find_element(PONUMBER_FIELD)560 po_number.send_keys(ponumber)561 end562 def account_executive(accountexecutive)563 wait = Selenium::WebDriver::Wait.new(:timeout => 10)564 wait.until {@driver.find_element(ACCOUNT_EXECUTIVE_DROPDOWN).displayed?}565 dropdown_list = @driver.find_element(ACCOUNT_EXECUTIVE_DROPDOWN)566 options = dropdown_list.find_elements(tag_name: 'option')567 options.each {|option| option.click if option.text == (accountexecutive)}568 end569 def commission(comissionschedule)570 wait = Selenium::WebDriver::Wait.new(:timeout => 10)571 wait.until {@driver.find_element(COMMISSION_SCHEDULE_DROPDOWN).displayed?}572 dropdown_list = @driver.find_element(COMMISSION_SCHEDULE_DROPDOWN)573 options = dropdown_list.find_elements(tag_name: 'option')574 options.each {|option| option.click if option.text == (comissionschedule)}575 end576 def cancel()577 wait = Selenium::WebDriver::Wait.new(:timeout => 5)578 wait.until {@driver.find_element(CANCEL_BTN).displayed?}579 cancel_popup = @driver.find_element(CANCEL_BTN)580 cancel_popup.click581 @driver.switch_to.default_content582 end583 def actions()584 #Use actions_(action) methods from here585 wait = Selenium::WebDriver::Wait.new(:timeout => 5)586 wait.until {@driver.find_element(ACTIONS_BTN).displayed?}587 actions_popup = @driver.find_element(ACTIONS_BTN)588 actions_popup.click589 end590 def actions_viewjob()591 #Only accessible in popup actions592 i = 0593 loopcount = 5594 wait = Selenium::WebDriver::Wait.new(:timeout => 5)595 wait.until {@driver.find_element(ACTIONS_VIEWJOB).displayed?}596 viewjob = @driver.find_element(ACTIONS_VIEWJOB)597 viewjob.click598 loop do599 i += 1600 @driver.switch_to.frame(0)601 begin602 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)603 wait2.until {@driver.find_element(JOB_NAME_FIELD).displayed?}604 rescue Selenium::WebDriver::Error::TimeOutError605 false606 end607 if608 begin609 @driver.find_element(JOB_NAME_FIELD).displayed? == true610 rescue Selenium::WebDriver::Error::NoSuchElementError611 false612 end613 break614 end615 if i == loopcount616 raise FrameError617 end618 end619 end620 def actions_viewcustomer()621 #Only accessible in popup actions622 i = 0623 loopcount = 5624 wait = Selenium::WebDriver::Wait.new(:timeout => 5)625 wait.until {@driver.find_element(ACTIONS_VIEWCUSTOMER).displayed?}626 viewcustomer = @driver.find_element(ACTIONS_VIEWCUSTOMER)627 viewcustomer.click628 loop do629 i += 1630 @driver.switch_to.frame(0)631 begin632 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)633 wait2.until {@driver.find_element(CUSTOMER_NAME_FIELD).displayed?}634 rescue Selenium::WebDriver::Error::TimeOutError635 false636 end637 if638 begin639 @driver.find_element(CUSTOMER_NAME_FIELD).displayed? == true640 rescue Selenium::WebDriver::Error::NoSuchElementError641 false642 end643 break644 end645 if i == loopcount646 raise FrameError647 end648 end649 end650 def actions_pushtoqbo()651 #Only accessible in popup actions652 wait = Selenium::WebDriver::Wait.new(:timeout => 5)653 wait.until {@driver.find_element(ACTIONS_PUSHTOQBO).displayed?}654 pushtoqbo = @driver.find_element(ACTIONS_PUSHTOQBO)655 pushtoqbo.click656 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)657 wait2.until {@driver.find_element(PUSH_CONFIRM).displayed?}658 confirm = @driver.find_element(PUSH_CONFIRM)659 confirm.click660 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)661 wait3.until {@driver.find_element(CANCEL_BTN).displayed?}662 end663 def actions_pushtons()664 #Only accessible in popup actions665 wait = Selenium::WebDriver::Wait.new(:timeout => 5)666 wait.until {@driver.find_element(ACTIONS_PUSHTONS).displayed?}667 pushtons = @driver.find_element(ACTIONS_PUSHTONS)668 pushtons.click669 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)670 wait2.until {@driver.find_element(PUSH_CONFIRM).displayed?}671 confirm = @driver.find_element(PUSH_CONFIRM)672 confirm.click673 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)674 wait3.until {@driver.find_element(CANCEL_BTN).displayed?}675 end676 def actions_pullfromqbo()677 #Only accessible in popup actions678 wait = Selenium::WebDriver::Wait.new(:timeout => 5)679 wait.until {@driver.find_element(ACTIONS_PULLFROMQBO).displayed?}680 pullfromqbo = @driver.find_element(ACTIONS_PULLFROMQBO)681 pullfromqbo.click682 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)683 wait2.until {@driver.find_element(CANCEL_BTN).displayed?}684 end685 def actions_viewinqbo()686 #Only accessible in popup actions687 wait = Selenium::WebDriver::Wait.new(:timeout => 5)688 wait.until {@driver.find_element(ACTIONS_VIEWINQBO).displayed?}689 viewqbo = @driver.find_element(ACTIONS_VIEWINQBO)690 viewqbo.click691 end692 def save()693 wait = Selenium::WebDriver::Wait.new(:timeout => 5)694 wait.until {@driver.find_element(SAVE_BTN).displayed?}695 save = @driver.find_element(SAVE_BTN)696 save.click697 end698 def save_close()699 wait = Selenium::WebDriver::Wait.new(:timeout => 5)700 wait.until {@driver.find_element(SAVE_AND_CLOSE_BTN).displayed?}701 save_and_close = @driver.find_element(SAVE_AND_CLOSE_BTN)702 save_and_close.click703 @driver.switch_to.default_content704 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)705 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}706 end707 #CSS Methods: Popup (Lines)708 def lines_tab()709 wait = Selenium::WebDriver::Wait.new(:timeout => 5)710 wait.until {@driver.find_element(LINES_TAB).displayed?}711 lines_tab = @driver.find_element(LINES_TAB)712 lines_tab.click713 end714 def line1_service_date(servicedate1)715 wait = Selenium::WebDriver::Wait.new(:timeout => 5)716 wait.until {@driver.find_element(LINE1_SERVICE_DATE_SPAN).displayed?}717 span_field = @driver.find_element(LINE1_SERVICE_DATE_SPAN)718 span_field.click719 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)720 wait2.until {@driver.find_element(LINE1_SERVICE_DATE).displayed?}721 servicedate_field = @driver.find_element(LINE1_SERVICE_DATE)722 servicedate_field.send_keys(servicedate1)723 end724 def line1_item(item1)725 wait = Selenium::WebDriver::Wait.new(:timeout => 5)726 wait.until {@driver.find_element(LINE1_ITEM_SPAN).displayed?}727 span_field = @driver.find_element(LINE1_ITEM_SPAN)728 span_field.click729 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)730 wait2.until {@driver.find_element(LINE1_SERVICE_DATE).displayed?}731 item_field = @driver.find_element(LINE1_SERVICE_DATE)732 item_field.send_keys(item1)733 sleep(1)734 @driver.action.send_keys(:enter).perform735 sleep(1)736 end737 def line1_description(description1)738 wait = Selenium::WebDriver::Wait.new(:timeout => 5)739 wait.until {@driver.find_element(LINE1_DESCRIPTION).displayed?}740 span_field = @driver.find_element(LINE1_DESCRIPTION)741 span_field.click742 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)743 wait2.until {@driver.find_element(LINE1_DESCRIPTION_TEXTAREA).displayed?}744 item_field = @driver.find_element(LINE1_DESCRIPTION_TEXTAREA)745 item_field.send_keys(description1)746 sleep(1)747 @driver.action.send_keys(:enter).perform748 sleep(1)749 end750 def line1_delete()751 wait = Selenium::WebDriver::Wait.new(:timeout => 5)752 wait.until {@driver.find_element(LINE1_DELETE).displayed?}753 trashcan = @driver.find_element(LINE1_DELETE)754 trashcan.click755 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)756 wait2.until {@driver.find_element(AJAX).displayed? == false}757 sleep(1)758 end759 def line2_service_date(servicedate2)760 wait = Selenium::WebDriver::Wait.new(:timeout => 5)761 wait.until {@driver.find_element(LINE2_SERVICE_DATE_SPAN).displayed?}762 span_field = @driver.find_element(LINE2_SERVICE_DATE_SPAN)763 span_field.click764 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)765 wait2.until {@driver.find_element(LINE2_SERVICE_DATE).displayed?}766 servicedate_field = @driver.find_element(LINE2_SERVICE_DATE)767 servicedate_field.send_keys(servicedate2)768 end769 def line2_item(item2)770 wait = Selenium::WebDriver::Wait.new(:timeout => 5)771 wait.until {@driver.find_element(LINE2_ITEM_SPAN).displayed?}772 span_field = @driver.find_element(LINE2_ITEM_SPAN)773 span_field.click774 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)775 wait2.until {@driver.find_element(LINE2_SERVICE_DATE).displayed?}776 item_field = @driver.find_element(LINE2_SERVICE_DATE)777 item_field.send_keys(item2)778 sleep(1)779 @driver.action.send_keys(:enter).perform780 sleep(1)781 end782 def line2_description(description2)783 wait = Selenium::WebDriver::Wait.new(:timeout => 5)784 wait.until {@driver.find_element(LINE2_DESCRIPTION).displayed?}785 span_field = @driver.find_element(LINE2_DESCRIPTION)786 span_field.click787 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)788 wait2.until {@driver.find_element(LINE2_DESCRIPTION_TEXTAREA).displayed?}789 item_field = @driver.find_element(LINE2_DESCRIPTION_TEXTAREA)790 item_field.send_keys(description2)791 sleep(1)792 @driver.action.send_keys(:enter).perform793 sleep(1)794 end795 def line2_delete()796 wait = Selenium::WebDriver::Wait.new(:timeout => 5)797 wait.until {@driver.find_element(LINE2_DELETE).displayed?}798 trashcan = @driver.find_element(LINE2_DELETE)799 trashcan.click800 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)801 wait2.until {@driver.find_element(AJAX).displayed? == false}802 sleep(1)803 end804 def add_lines()805 wait = Selenium::WebDriver::Wait.new(:timeout => 5)806 wait.until {@driver.find_element(ADD_LINES).displayed?}807 @driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")808 button = @driver.find_element(ADD_LINES)809 button.click810 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)811 wait2.until {@driver.find_element(AJAX).displayed? == false}812 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)813 wait3.until {@driver.find_element(NEW_LINE_VERIFY).displayed?}814 end815 def clear_lines()816 wait = Selenium::WebDriver::Wait.new(:timeout => 5)817 wait.until {@driver.find_element(CLEAR_LINES).displayed?}818 @driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")819 button = @driver.find_element(CLEAR_LINES)820 button.click821 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)822 wait2.until {@driver.find_element(AJAX).displayed? == false}823 sleep(1) #This button has nothing for me to use to wait for.824 end825 def add_description()826 wait = Selenium::WebDriver::Wait.new(:timeout => 5)827 wait.until {@driver.find_element(ADD_DESCRIPTION).displayed?}828 @driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")829 button = @driver.find_element(ADD_DESCRIPTION)830 button.click831 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)832 wait2.until {@driver.find_element(AJAX).displayed? == false}833 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)834 wait3.until {@driver.find_element(NEW_LINE2_VERIFY).displayed?}835 end836 def subtotal()837 subtotal = @driver.find_element(SUBTOTAL).text.gsub(/[$,]/,'').to_f838 end839 def select_tax(taxcode)840 dropdown_list = @driver.find_element(TAX_DROPDOWN)841 options = dropdown_list.find_elements(tag_name: 'option')842 options.each {|option| option.click if option.text == (taxcode)}843 end844 def taxtotal()845 taxtotal = @driver.find_element(TAXTOTAL).value.to_f846 end847 def total()848 total = @driver.find_element(TOTAL).text849 end850 #CSS Methods: Popup (Contacts)851 def contacts_tab()852 wait = Selenium::WebDriver::Wait.new(:timeout => 5)853 wait.until {@driver.find_element(CUSTOMER_CONTACTS_TAB).displayed?}854 contacts_tab = @driver.find_element(CUSTOMER_CONTACTS_TAB)855 contacts_tab.click856 end857 #Use Class - Contacts Resource from here858 #CSS Methods: Popup (Notes)859 def notes_tab()860 wait = Selenium::WebDriver::Wait.new(:timeout => 5)861 wait.until {@driver.find_element(NOTES_TAB).displayed?}862 notes_tab = @driver.find_element(NOTES_TAB)863 notes_tab.click864 end865 def customer_memo(customermemo)866 wait = Selenium::WebDriver::Wait.new(:timeout => 5)867 wait.until {@driver.find_element(CUSTOMER_MEMO_FIELD).displayed?}868 customer_memo = @driver.find_element(CUSTOMER_MEMO_FIELD)869 customer_memo.send_keys(customermemo)870 end871 def private_notes(privatenotes)872 wait = Selenium::WebDriver::Wait.new(:timeout => 5)873 wait.until {@driver.find_element(PRIVATE_NOTES_FIELD).displayed?}874 private_notes = @driver.find_element(PRIVATE_NOTES_FIELD)875 private_notes.send_keys(privatenotes)876 end877 #CSS Methods: Popup (Activities)878 def activities_tab()879 wait = Selenium::WebDriver::Wait.new(:timeout => 5)880 wait.until {@driver.find_element(ACTIVITIES_TAB).displayed?}881 activities_tab = @driver.find_element(ACTIVITIES_TAB)882 activities_tab.click883 end884 def search_activity(searchactivity)885 wait = Selenium::WebDriver::Wait.new(:timeout => 5)886 wait.until {@driver.find_element(SEARCH_ACTIVITY).displayed?}887 activity_search = @driver.find_element(SEARCH_ACTIVITY)888 activity_search.send_keys(searchactivity)889 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)890 wait2.until {@driver.find_element(INVOICE_ACTIVITY_SEARCH_BTN).displayed?}891 search_confirm = @driver.find_element(INVOICE_ACTIVITY_SEARCH_BTN)892 search_confirm.click893 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)894 wait3.until {@driver.find_element(TOP_ACTIVITY_DESCRIPTION).downcase.include?(searchactivity.downcase)}895 end896 def top_activity()897 i = 0898 loopcount = 5899 wait = Selenium::WebDriver::Wait.new(:timeout => 5)900 wait.until {@driver.find_element(TOP_ACTIVITY).displayed?}901 top_refnumber = @driver.find_element(TOP_ACTIVITY)902 top_refnumber.click...
Class - Estimates Resource.rb
Source:Class - Estimates Resource.rb
...164 loopcount = 5165 f = 0166 frameloopcount = 10167 select_customer = @driver.find_element(CUSTOMER_SEARCH_FIELD)168 select_customer.send_keys(selectcustomer)169 sleep(1)170 @driver.action.send_keys(:enter).perform171 sleep(1)172 select_customer_next = @driver.find_element(CUSTOMER_NEXT_BTN)173 select_customer_next.click174 loop do175 i += 1176 loop do177 f += 1178 begin179 @driver.switch_to.default_content180 @driver.switch_to.frame(0)181 rescue Selenium::WebDriver::Error::NoSuchFrameError182 false183 end184 break185 if f == frameloopcount186 raise FrameError187 end188 end189 begin190 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)191 wait2.until {@driver.find_element(NAME_FIELD).displayed?}192 rescue Selenium::WebDriver::Error::TimeoutError193 false194 end195 if196 begin197 @driver.find_element(NAME_FIELD).displayed? == true198 rescue Selenium::WebDriver::Error::NoSuchElementError199 false200 end201 break202 end203 if i == loopcount204 raise FrameError205 end206 end207 end208 def dev_select_customer(selectcustomer)209 i = 0210 loopcount = 5211 f= 0212 frameloopcount = 10213 select_customer = @driver.find_element(CUSTOMER_SEARCH_FIELD)214 select_customer.send_keys(selectcustomer)215 sleep(2)216 @driver.action.send_keys(:enter).perform217 sleep(2)218 select_customer_next = @driver.find_element(CUSTOMER_NEXT_BTN)219 select_customer_next.click220 loop do221 i += 1222 loop do223 f += 1224 begin225 @driver.switch_to.default_content226 @driver.switch_to.frame(0)227 rescue Selenium::WebDriver::Error::NoSuchFrameError228 false229 end230 break231 if f == frameloopcount232 raise FrameError233 end234 end235 begin236 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)237 wait2.until {@driver.find_element(NAME_FIELD).displayed?}238 rescue Selenium::WebDriver::Error::TimeoutError239 false240 end241 if242 begin243 @driver.find_element(NAME_FIELD).displayed? == true244 rescue Selenium::WebDriver::Error::NoSuchElementError245 false246 end247 break248 end249 if i == loopcount250 raise FrameError251 end252 end253 end254 def top()255 top_record = @driver.find_element(TOP_ESTIMATE)256 end257 def top_refnumber()258 top_refnumber = @driver.find_element(TOP_REFNUMBER)259 end260 def top_status()261 top_refnumber = @driver.find_element(TOP_STATUS)262 end263 def top_stage()264 top_refnumber = @driver.find_element(TOP_STAGE)265 end266 def top_type()267 top_refnumber = @driver.find_element(TOP_TYPE)268 end269 def top_open()270 i = 0271 loopcount = 5272 wait = Selenium::WebDriver::Wait.new(:timeout => 5)273 wait.until {@driver.find_element(TOP_REFNUMBER).displayed?}274 top_refnumber = @driver.find_element(TOP_REFNUMBER)275 top_refnumber.click276 loop do277 i += 1278 @driver.switch_to.frame(0)279 begin280 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)281 wait2.until {@driver.find_element(NAME_FIELD).displayed?}282 rescue Selenium::WebDriver::Error::TimeoutError283 false284 end285 if286 begin287 @driver.find_element(NAME_FIELD).displayed? == true288 rescue Selenium::WebDriver::Error::NoSuchElementError289 false290 end291 break292 end293 if i == loopcount294 raise FrameError295 end296 end297 end298 def top_actions()299 wait = Selenium::WebDriver::Wait.new(:timeout => 5)300 wait.until {@driver.find_element(TOP_ESTIMATE_ACTIONS).displayed?}301 top_actions = @driver.find_element(TOP_ESTIMATE_ACTIONS)302 top_actions.click303 end304 def actions_createactivity()305 i = 0306 loopcount = 5307 wait = Selenium::WebDriver::Wait.new(:timeout => 5)308 wait.until {@driver.find_element(ACTIONS_CREATEACTIVITY).displayed?}309 top_createactivity = @driver.find_element(ACTIONS_CREATEACTIVITY)310 top_createactivity.click311 loop do312 i += 1313 @driver.switch_to.frame(0)314 begin315 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)316 wait2.until {@driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed?}317 rescue Selenium::WebDriver::Error::TimeoutError318 false319 end320 if321 begin322 @driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed? == true323 rescue Selenium::WebDriver::Error::NoSuchElementError324 false325 end326 break327 end328 if i == loopcount329 raise FrameError330 end331 end332 end333 def actions_createinvoice()334 i = 0335 loopcount = 5336 wait = Selenium::WebDriver::Wait.new(:timeout => 5)337 wait.until {@driver.find_element(ACTIONS_CREATEINVOICE).displayed?}338 top_createinvoice = @driver.find_element(ACTIONS_CREATEINVOICE)339 top_createinvoice.click340 loop do341 i += 1342 @driver.switch_to.frame(0)343 begin344 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)345 wait2.until {@driver.find_element(INVOICE_PONUMBER_FIELD).displayed?}346 rescue Selenium::WebDriver::Error::TimeoutError347 false348 end349 if350 begin351 @driver.find_element(INVOICE_PONUMBER_FIELD).displayed? == true352 rescue Selenium::WebDriver::Error::NoSuchElementError353 false354 end355 break356 end357 if i == loopcount358 raise FrameError359 end360 end361 end362 def actions_documents()363 i = 0364 loopcount = 5365 wait = Selenium::WebDriver::Wait.new(:timeout => 5)366 wait.until {@driver.find_element(ACTIONS_DOCUMENTS).displayed?}367 top_documents = @driver.find_element(ACTIONS_DOCUMENTS)368 top_documents.click369 loop do370 i += 1371 @driver.switch_to.frame(0)372 begin373 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)374 wait2.until {@driver.find_element(DOCUMENTS_SHOWHIDE_UPLOADER).displayed?}375 rescue Selenium::WebDriver::Error::TimeoutError376 false377 end378 if379 begin380 @driver.find_element(DOCUMENTS_SHOWHIDE_UPLOADER).displayed? == true381 rescue Selenium::WebDriver::Error::NoSuchElementError382 false383 end384 break385 end386 if i == loopcount387 raise FrameError388 end389 end390 end391 def actions_printemail()392 i = 0393 loopcount = 5394 wait = Selenium::WebDriver::Wait.new(:timeout => 5)395 wait.until {@driver.find_element(ACTIONS_PRINTEMAIL).displayed?}396 top_printemail = @driver.find_element(ACTIONS_PRINTEMAIL)397 top_printemail.click398 loop do399 i += 1400 @driver.switch_to.frame(0)401 begin402 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)403 wait2.until {@driver.find_element(PRINTEMAIL_PDF_CHECKBOX).displayed?}404 rescue Selenium::WebDriver::Error::TimeoutError405 false406 end407 if408 begin409 @driver.find_element(PRINTEMAIL_PDF_CHECKBOX).displayed? == true410 rescue Selenium::WebDriver::Error::NoSuchElementError411 false412 end413 break414 end415 if i == loopcount416 raise FrameError417 end418 end419 end420 def actions_duplicateestimate()421 i = 0422 loopcount = 5423 wait = Selenium::WebDriver::Wait.new(:timeout => 5)424 wait.until {@driver.find_element(ACTIONS_DUPLICATEESTIMATE).displayed?}425 top_duplicate = @driver.find_element(ACTIONS_DUPLICATEESTIMATE)426 top_duplicate.click427 loop do428 i += 1429 @driver.switch_to.frame(0)430 begin431 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)432 wait2.until {@driver.find_element(NAME_FIELD).displayed?}433 rescue Selenium::WebDriver::Error::TimeoutError434 false435 end436 if437 begin438 @driver.find_element(NAME_FIELD).displayed? == true439 rescue Selenium::WebDriver::Error::NoSuchElementError440 false441 end442 break443 end444 if i == loopcount445 raise FrameError446 end447 end448 end449 def actions_makeinactive()450 currenttopref = @driver.find_element(TOP_REFNUMBER).text451 wait = Selenium::WebDriver::Wait.new(:timeout => 5)452 wait.until {@driver.find_element(ACTIONS_MAKEINACTIVE).displayed?}453 top_makeinactive = @driver.find_element(ACTIONS_MAKEINACTIVE)454 top_makeinactive.click455 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)456 wait2.until {@driver.find_element(PUSH_CONFIRM).displayed?}457 confirm = @driver.find_element(PUSH_CONFIRM)458 confirm.click459 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)460 wait3.until {@driver.find_element(TOP_REFNUMBER).text != currenttopref}461 end462 def search_estimate(searchname)463 wait = Selenium::WebDriver::Wait.new(:timeout => 5)464 wait.until {@driver.find_element(SEARCH_FIELD).displayed?}465 record_search = @driver.find_element(SEARCH_FIELD)466 record_search.send_keys(searchname)467 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)468 wait2.until {@driver.find_element(SEARCH_BTN).displayed?}469 search_confirm = @driver.find_element(SEARCH_BTN)470 search_confirm.click471 wait3 = Selenium::WebDriver::Wait.new(:timeout => 10)472 wait3.until {@driver.find_element(TOP_ESTIMATE).text.downcase.include?(searchname.downcase)}473 end474 def search_estimateid(searchname)475 i = 0476 loopcount = 5477 loop do478 wait = Selenium::WebDriver::Wait.new(:timeout => 5)479 if480 begin481 wait.until {@driver.find_element(ID_COLUMN).displayed?} == true482 rescue Selenium::WebDriver::Error::StaleElementReferenceError483 false484 end485 break486 if i == loopcount487 raise StaleError488 end489 end490 end491 estimate_search = @driver.find_element(ID_COLUMN)492 estimate_search.send_keys(searchname)493 @driver.action.send_keys(:enter).perform494 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)495 wait2.until {@driver.find_element(TOP_REFNUMBER).text.include?(searchname)}496 end497 def search_estimateid_field()498 field = @driver.find_element(ID_COLUMN)499 end500 def search_estimatename(searchname)501 i = 0502 loopcount = 5503 loop do504 wait = Selenium::WebDriver::Wait.new(:timeout => 5)505 if506 begin507 wait.until {@driver.find_element(NAME_COLUMN).displayed?} == true508 rescue Selenium::WebDriver::Error::StaleElementReferenceError509 false510 end511 break512 if i == loopcount513 raise StaleError514 end515 end516 end517 estimate_search = @driver.find_element(NAME_COLUMN)518 estimate_search.send_keys(searchname)519 @driver.action.send_keys(:enter).perform520 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)521 wait2.until {@driver.find_element(TOP_ESTIMATE).text.downcase.include?(searchname.downcase)}522 end523 def search_estimateid_field()524 field = @driver.find_element(NAME_COLUMN)525 end526 def search_reset()527 currentrecords = @driver.find_element(class: "Counter_Message").text528 wait = Selenium::WebDriver::Wait.new(:timeout => 5)529 wait.until {@driver.find_element(RESET_BTN).displayed?}530 search_reset = @driver.find_element(RESET_BTN)531 search_reset.click532 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)533 wait2.until {@driver.find_element(class: "Counter_Message").text != currentrecords}534 end535 def grid_options()536 wait = Selenium::WebDriver::Wait.new(:timeout => 5)537 wait.until {@driver.find_element(GRID_OPTIONS_DROPDOWN).displayed?}538 grid_options = @driver.find_element(GRID_OPTIONS_DROPDOWN)539 grid_options.click540 end541 def export_estimates()542 wait = Selenium::WebDriver::Wait.new(:timeout => 5)543 wait.until {@driver.find_element(EXPORT_ESTIMATES).displayed?}544 export_estimates = @driver.find_element(EXPORT_ESTIMATES)545 export_estimates.click546 sleep(2)547 end548 def show_inactives()549 wait = Selenium::WebDriver::Wait.new(:timeout => 5)550 wait.until {@driver.find_element(SHOW_INACTIVES).displayed?}551 show_inactives = @driver.find_element(SHOW_INACTIVES)552 show_inactives.click553 end554 def grid_total()555 gridtotal = @driver.find_element(GRID_TOTAL)556 end557 def resource_performance()558 navigationStart = @driver.execute_script("return window.performance.timing.navigationStart")559 responseStart = @driver.execute_script("return window.performance.timing.responseStart")560 domComplete = @driver.execute_script("return window.performance.timing.domComplete")561 loadPerformance = domComplete - navigationStart562 wait = Selenium::WebDriver::Wait.new(:timeout => 20)563 wait.until {@driver.find_element(GRID_TOTAL).text != "0 records"}564 estimates_records = @driver.find_element(GRID_TOTAL)565 estimates_count = estimates_records.text566 print "Estimates: \n"567 print "%s \n" % estimates_count568 print "Load Time: %s ms \n\n" % loadPerformance569 end570 #CSS Methods: Popup571 def name(estimatename)572 estimate_name = @driver.find_element(NAME_FIELD)573 estimate_name.send_keys(estimatename)574 end575 def location(locationselect)576 dropdown_list = @driver.find_element(LOCATION_DROPDOWN)577 options = dropdown_list.find_elements(tag_name: 'option')578 options.each {|option| option.click if option.text == (locationselect)}579 end580 def type(typeselect)581 dropdown_list = @driver.find_element(TYPE_DROPDOWN)582 options = dropdown_list.find_elements(tag_name: 'option')583 options.each {|option| option.click if option.text == (typeselect)}584 end585 def stage(stageselect)586 dropdown_list = @driver.find_element(STAGE_DROPDOWN)587 options = dropdown_list.find_elements(tag_name: 'option')588 options.each {|option| option.click if option.text == (stageselect)}589 end590 def customer(customername)591 customer_name = @driver.find_element(CUSTOMER_FIELD)592 customer_name.send_keys(customername)593 end594 def patrol(patrolname)595 patrol_name = @driver.find_element(PATROL_FIELD)596 patrol_name.send_keys(patrolname)597 end598 def effective_on(effectiveon)599 estimate_name = @driver.find_element(EFFECTIVEON_FIELD)600 estimate_name.send_keys(effectiveon)601 end602 def expires_on(ponumber)603 po_number = @driver.find_element(EXPIRESON_FIELD)604 po_number.send_keys(ponumber)605 end606 def account_executive(accountexecutive)607 dropdown_list = @driver.find_element(ACCOUNT_EXECUTIVE_DROPDOWN)608 options = dropdown_list.find_elements(tag_name: 'option')609 options.each {|option| option.click if option.text == (accountexecutive)}610 end611 def nte(ntefield)612 po_number = @driver.find_element(NTE_FIELD)613 po_number.send_keys(ntefield)614 end615 def cancel()616 wait = Selenium::WebDriver::Wait.new(:timeout => 5)617 wait.until {@driver.find_element(CANCEL_BTN).displayed?}618 cancel_popup = @driver.find_element(CANCEL_BTN)619 cancel_popup.click620 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)621 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}622 end623 def actions()624 #Use actions_(action) methods from here625 wait = Selenium::WebDriver::Wait.new(:timeout => 5)626 wait.until {@driver.find_element(ACTIONS_BTN).displayed?}627 actions_popup = @driver.find_element(ACTIONS_BTN)628 actions_popup.click629 end630 def save()631 wait = Selenium::WebDriver::Wait.new(:timeout => 5)632 wait.until {@driver.find_element(SAVE_BTN).displayed?}633 save = @driver.find_element(SAVE_BTN)634 save.click635 end636 def save_close()637 wait = Selenium::WebDriver::Wait.new(:timeout => 5)638 wait.until {@driver.find_element(SAVE_AND_CLOSE_BTN).displayed?}639 save_and_close = @driver.find_element(SAVE_AND_CLOSE_BTN)640 save_and_close.click641 @driver.switch_to.default_content642 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)643 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}644 end645 #CSS Methods: Popup (Lines)646 def lines_tab()647 wait = Selenium::WebDriver::Wait.new(:timeout => 5)648 wait.until {@driver.find_element(LINES_TAB).displayed?}649 lines_tab = @driver.find_element(LINES_TAB)650 lines_tab.click651 end652 def line1_item(item1)653 wait = Selenium::WebDriver::Wait.new(:timeout => 5)654 wait.until {@driver.find_element(LINE1_ITEM_SPAN).displayed?}655 span_field = @driver.find_element(LINE1_ITEM_SPAN)656 span_field.click657 wait = Selenium::WebDriver::Wait.new(:timeout => 5)658 wait.until {@driver.find_element(LINE1_SERVICE_DATE).displayed?}659 item_field = @driver.find_element(LINE1_SERVICE_DATE)660 item_field.send_keys(item1)661 sleep(1)662 @driver.action.send_keys(:enter).perform663 sleep(1)664 end665 #CSS Methods: Popup (Scheduling)666 def scheduling_tab()667 wait = Selenium::WebDriver::Wait.new(:timeout => 5)668 wait.until {@driver.find_element(SCHEDULING_TAB).displayed?}669 scheduling_tab = @driver.find_element(SCHEDULING_TAB)670 scheduling_tab.click671 end672 def estimate_cancel(jobcancel)673 wait = Selenium::WebDriver::Wait.new(:timeout => 5)674 wait.until {@driver.find_element(JOB_CANCELED_FIELD).displayed?}675 jobcanceled_field = @driver.find_element(JOB_CANCELED_FIELD)676 jobcanceled_field.send_keys(jobcancel)677 end678 def estimate_hold(jobhold)679 wait = Selenium::WebDriver::Wait.new(:timeout => 5)680 wait.until {@driver.find_element(JOB_HOLD_FIELD).displayed?}681 jobhold_field = @driver.find_element(JOB_HOLD_FIELD)682 jobhold_field.send_keys(jobhold)683 end684 def estimate_complete(jobcomplete)685 wait = Selenium::WebDriver::Wait.new(:timeout => 5)686 wait.until {@driver.find_element(JOB_COMPLETED_FIELD).displayed?}687 jobcompleted_field = @driver.find_element(JOB_COMPLETED_FIELD)688 jobcompleted_field.send_keys(jobcomplete)689 end690 #CSS Methods: Popup (Contacts)691 def contacts_tab()692 wait = Selenium::WebDriver::Wait.new(:timeout => 5)693 wait.until {@driver.find_element(CUSTOMER_CONTACTS_TAB).displayed?}694 contacts_tab = @driver.find_element(CUSTOMER_CONTACTS_TAB)695 contacts_tab.click696 end697 #Use Class - Contacts Resource from here698 #CSS Methods: Popup (Notes)699 def notes_tab()700 wait = Selenium::WebDriver::Wait.new(:timeout => 5)701 wait.until {@driver.find_element(NOTES_TAB).displayed?}702 notes_tab = @driver.find_element(NOTES_TAB)703 notes_tab.click704 end705 def scope_of_work(scopeofwork)706 wait = Selenium::WebDriver::Wait.new(:timeout => 5)707 wait.until {@driver.find_element(SCOPE_OF_WORK_FIELD).displayed?}708 scope_of_work = @driver.find_element(SCOPE_OF_WORK_FIELD)709 scope_of_work.send_keys(scopeofwork)710 end711 def additional_notes(additionalnotes)712 wait = Selenium::WebDriver::Wait.new(:timeout => 5)713 wait.until {@driver.find_element(ADDITIONAL_NOTES_FIELD).displayed?}714 additional_notes = @driver.find_element(ADDITIONAL_NOTES_FIELD)715 additional_notes.send_keys(additionalnotes)716 end717 def special_instructions(specialinstructions)718 wait = Selenium::WebDriver::Wait.new(:timeout => 5)719 wait.until {@driver.find_element(SPECIAL_INSTRUCTIONS_FIELD).displayed?}720 special_instructions = @driver.find_element(SPECIAL_INSTRUCTIONS_FIELD)721 special_instructions.send_keys(specialinstructions)722 end723 def private_notes(privatenotes)724 wait = Selenium::WebDriver::Wait.new(:timeout => 5)725 wait.until {@driver.find_element(PRIVATE_NOTES_FIELD).displayed?}726 private_notes = @driver.find_element(PRIVATE_NOTES_FIELD)727 private_notes.send_keys(privatenotes)728 end729 #CSS Methods: Popup (Activities)730 def activities_tab()731 wait = Selenium::WebDriver::Wait.new(:timeout => 5)732 wait.until {@driver.find_element(ACTIVITIES_TAB).displayed?}733 activities_tab = @driver.find_element(ACTIVITIES_TAB)734 activities_tab.click735 end736 def search_activity(searchactivity)737 wait = Selenium::WebDriver::Wait.new(:timeout => 5)738 wait.until {@driver.find_element(SEARCH_ACTIVITY).displayed?}739 activity_search = @driver.find_element(SEARCH_ACTIVITY)740 activity_search.send_keys(searchactivity)741 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)742 wait2.until {@driver.find_element(ESTIMATE_ACTIVITY_SEARCH_BTN).displayed?}743 search_confirm = @driver.find_element(ESTIMATE_ACTIVITY_SEARCH_BTN)744 search_confirm.click745 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)746 wait3.until {@driver.find_element(TOP_ACTIVITY_DESCRIPTION).downcase.include?(searchactivity.downcase)}747 end748 def top_activity()749 i = 0750 loopcount = 5751 wait = Selenium::WebDriver::Wait.new(:timeout => 5)752 wait.until {@driver.find_element(TOP_ACTIVITY).displayed?}753 top_refnumber = @driver.find_element(TOP_ACTIVITY)754 top_refnumber.click755 loop do756 i += 1757 @driver.switch_to.frame(0)758 begin759 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)760 wait2.until {@driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed?}761 rescue Selenium::WebDriver::Error::TimeoutError762 false763 end764 if765 begin766 @driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed? == true767 rescue Selenium::WebDriver::Error::NoSuchElementError768 false769 end770 break771 end772 if i == loopcount773 raise FrameError774 end775 end776 end777 def top_activitydescription()778 top_activitydescription = @driver.find_element(TOP_ACTIVITY_DESCRIPTION)779 end780 #CSS Methods: Popup (Jobs)781 def jobs_tab()782 wait = Selenium::WebDriver::Wait.new(:timeout => 5)783 wait.until {@driver.find_element(JOBS_TAB).displayed?}784 jobs_tab = @driver.find_element(JOBS_TAB)785 jobs_tab.click786 end787 def search_job(searchjob)788 wait = Selenium::WebDriver::Wait.new(:timeout => 5)789 wait.until {@driver.find_element(SEARCH_JOB).displayed?}790 job_search = @driver.find_element(SEARCH_JOB)791 job_search.send_keys(searchjob)792 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)793 wait2.until {@driver.find_element(ESTIMATE_JOB_SEARCH_BTN).displayed?}794 search_confirm = @driver.find_element(ESTIMATE_JOB_SEARCH_BTN)795 search_confirm.click796 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)797 wait3.until {@driver.find_element(TOP_JOB).downcase.include?(searchactivity.downcase)}798 end799 def top_invoice()800 i = 0801 loopcount = 5802 wait = Selenium::WebDriver::Wait.new(:timeout => 5)803 wait.until {@driver.find_element(TOP_JOB).displayed?}804 top_refnumber = @driver.find_element(TOP_JOB)805 top_refnumber.click...
Class - Patrols Resource.rb
Source:Class - Patrols Resource.rb
...350 def search_patrol(searchname)351 wait = Selenium::WebDriver::Wait.new(:timeout => 5)352 wait.until {@driver.find_element(SEARCH_FIELD).displayed?}353 patrol_search = @driver.find_element(SEARCH_FIELD)354 patrol_search.send_keys(searchname)355 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)356 wait2.until {@driver.find_element(SEARCH_BTN).displayed?}357 search_confirm = @driver.find_element(SEARCH_BTN)358 search_confirm.click359 wait3 = Selenium::WebDriver::Wait.new(:timeout => 10)360 wait3.until {(@driver.find_element(TOP_PATROL).text.downcase + @driver.find_element(TOP_PATROL_CUSTOMER).text.downcase).include?(searchname)}361 end362 def search_patrolid(searchname)363 i = 0364 loopcount = 5365 loop do366 wait = Selenium::WebDriver::Wait.new(:timeout => 5)367 if368 begin369 wait.until {@driver.find_element(ID_COLUMN).displayed?} == true370 rescue Selenium::WebDriver::Error::StaleElementReferenceError371 false372 end373 break374 if i == loopcount375 raise StaleError376 end377 end378 end379 patrol_search = @driver.find_element(ID_COLUMN)380 patrol_search.send_keys(searchname)381 @driver.action.send_keys(:enter).perform382 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)383 wait2.until {@driver.find_element(TOP_REFNUMBER).text.include?(searchname)}384 end385 def search_patrolid_field()386 field = @driver.find_element(ID_COLUMN)387 end388 def search_patrolname(searchname)389 i = 0390 loopcount = 5391 loop do392 wait = Selenium::WebDriver::Wait.new(:timeout => 5)393 if394 begin395 wait.until {@driver.find_element(NAME_COLUMN).displayed?} == true396 rescue Selenium::WebDriver::Error::StaleElementReferenceError397 false398 end399 break400 if i == loopcount401 raise StaleError402 end403 end404 end405 patrol_search = @driver.find_element(NAME_COLUMN)406 patrol_search.send_keys(searchname)407 @driver.action.send_keys(:enter).perform408 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)409 wait2.until {@driver.find_element(TOP_PATROL).text.downcase.include?(searchname)}410 end411 def search_patrolname_field()412 field = @driver.find_element(NAME_COLUMN)413 end414 def search_reset()415 currentrecords = @driver.find_element(class: "Counter_Message").text416 wait = Selenium::WebDriver::Wait.new(:timeout => 5)417 wait.until {@driver.find_element(RESET_BTN).displayed?}418 search_reset = @driver.find_element(RESET_BTN)419 search_reset.click420 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)421 wait2.until {@driver.find_element(class: "Counter_Message").text != currentrecords}422 end423 def grid_options()424 wait = Selenium::WebDriver::Wait.new(:timeout => 5)425 wait.until {@driver.find_element(GRID_OPTIONS_DROPDOWN).displayed?}426 grid_options = @driver.find_element(GRID_OPTIONS_DROPDOWN)427 grid_options.click428 sleep(2)429 end430 def export_patrols()431 wait = Selenium::WebDriver::Wait.new(:timeout => 5)432 wait.until {@driver.find_element(EXPORT_PATROLS).displayed?}433 export_patrols = @driver.find_element(EXPORT_PATROLS)434 export_patrols.click435 sleep(2)436 end437 def show_inactives()438 wait = Selenium::WebDriver::Wait.new(:timeout => 5)439 wait.until {@driver.find_element(SHOW_INACTIVES).displayed?}440 show_inactives = @driver.find_element(SHOW_INACTIVES)441 show_inactives.click442 end443 def show_oldpatrols()444 wait = Selenium::WebDriver::Wait.new(:timeout => 5)445 wait.until {@driver.find_element(SHOW_OLDPATROLS).displayed?}446 show_oldpatrols = @driver.find_element(SHOW_OLDPATROLS)447 show_oldpatrols.click448 sleep(2)449 end450 def grid_total()451 gridtotal = @driver.find_element(GRID_TOTAL)452 end453 def resource_performance()454 navigationStart = @driver.execute_script("return window.performance.timing.navigationStart")455 responseStart = @driver.execute_script("return window.performance.timing.responseStart")456 domComplete = @driver.execute_script("return window.performance.timing.domComplete")457 loadPerformance = domComplete - navigationStart458 wait = Selenium::WebDriver::Wait.new(:timeout => 20)459 wait.until {@driver.find_element(GRID_TOTAL).text != "0 records"}460 patrols_records = @driver.find_element(GRID_TOTAL)461 patrols_count = patrols_records.text462 print "Patrols: \n"463 print "%s \n" % patrols_count464 print "Load Time: %s ms \n\n" % loadPerformance465 end466 #CSS Methods: Popup467 def submitted_name(submittedname)468 submitted_name = @driver.find_element(SUBMITTED_NAME_FIELD)469 submitted_name.send_keys(submittedname)470 end471 def location(locationselect)472 dropdown_list = @driver.find_element(LOCATION_DROPDOWN)473 options = dropdown_list.find_elements(tag_name: 'option')474 options.each {|option| option.click if option.text == (locationselect)}475 end476 def service_needed(serviceneeded)477 service_needed = @driver.find_element(SERVICE_NEEDED_FIELD)478 service_needed.send_keys(serviceneeded)479 end480 def account_executive(accountexecutive)481 dropdown_list = @driver.find_element(ACCOUNT_EXECUTIVE_DROPDOWN)482 options = dropdown_list.find_elements(tag_name: 'option')483 options.each {|option| option.click if option.text == (accountexecutive)}484 end485 def bad_patrol_type(badpatroltype)486 dropdown_list = @driver.find_element(BAD_PATROL_TYPE_DROPDOWN)487 options = dropdown_list.find_elements(tag_name: 'option')488 options.each {|option| option.click if option.text == (badpatroltype)}489 end490 def date_completed(datecompleted)491 date_completed = @driver.find_element(DATE_COMPLETED_FIELD)492 date_completed.send_keys(datecompleted)493 end494 def customer(customer)495 customer_enter = @driver.find_element(CUSTOMER_FIELD)496 customer_enter.send_keys(customer)497 sleep(3)498 @driver.action.send_keys(:enter).perform499 sleep(1)500 wait = Selenium::WebDriver::Wait.new(:timeout => 5)501 wait.until {@driver.find_element(VIEW_CUSTOMER_LINK).displayed?}502 end503 def dev_customer(customer)504 customer_enter = @driver.find_element(CUSTOMER_FIELD)505 customer_enter.send_keys(customer)506 sleep(3)507 @driver.action.send_keys(:enter).perform508 wait = Selenium::WebDriver::Wait.new(:timeout => 5)509 wait.until {@driver.find_element(VIEW_CUSTOMER_LINK).displayed?}510 end511 def cancel()512 wait = Selenium::WebDriver::Wait.new(:timeout => 5)513 wait.until {@driver.find_element(CANCEL_BTN).displayed?}514 cancel_popup = @driver.find_element(CANCEL_BTN)515 cancel_popup.click516 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)517 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}518 end519 def actions()520 #Use actions_(action) methods from here521 wait = Selenium::WebDriver::Wait.new(:timeout => 5)522 wait.until {@driver.find_element(ACTIONS_BTN).displayed?}523 actions_popup = @driver.find_element(ACTIONS_BTN)524 actions_popup.click525 end526 def save()527 wait = Selenium::WebDriver::Wait.new(:timeout => 5)528 wait.until {@driver.find_element(SAVE_BTN).displayed?}529 save = @driver.find_element(SAVE_BTN)530 save.click531 end532 def save_close()533 wait = Selenium::WebDriver::Wait.new(:timeout => 5)534 wait.until {@driver.find_element(SAVE_AND_CLOSE_BTN).displayed?}535 save_and_close = @driver.find_element(SAVE_AND_CLOSE_BTN)536 save_and_close.click537 @driver.switch_to.default_content538 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)539 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}540 end541 #CSS Methods: Popup (Contact Info Tab)542 def contact_info_tab()543 wait = Selenium::WebDriver::Wait.new(:timeout => 5)544 wait.until {@driver.find_element(CONTACT_INFO_TAB).displayed?}545 contact_info_tab = @driver.find_element(CONTACT_INFO_TAB)546 contact_info_tab.click547 end548 def site_name(sitename)549 wait = Selenium::WebDriver::Wait.new(:timeout => 5)550 wait.until {@driver.find_element(NAME_FIELD).displayed?}551 sitename_field = @driver.find_element(NAME_FIELD)552 sitename_field.send_keys(sitename)553 end554 def site_street(sitestreet)555 wait = Selenium::WebDriver::Wait.new(:timeout => 5)556 wait.until {@driver.find_element(STREET_FIELD).displayed?}557 sitestreet_field = @driver.find_element(STREET_FIELD)558 sitestreet_field.send_keys(sitestreet)559 end560 def site_state(sitestate)561 wait = Selenium::WebDriver::Wait.new(:timeout => 5)562 wait.until {@driver.find_element(STATE_FIELD).displayed?}563 sitestate_field = @driver.find_element(STATE_FIELD)564 sitestate_field.send_keys(sitestate)565 end566 def site_zip(sitezip)567 wait = Selenium::WebDriver::Wait.new(:timeout => 5)568 wait.until {@driver.find_element(POSTAL_CODE_FIELD).displayed?}569 sitezip_field = @driver.find_element(POSTAL_CODE_FIELD)570 sitezip_field.send_keys(sitezip)571 end572 def site_country(sitecountry)573 wait = Selenium::WebDriver::Wait.new(:timeout => 5)574 wait.until {@driver.find_element(COUNTRY_FIELD).displayed?}575 sitecountry_field = @driver.find_element(COUNTRY_FIELD)576 sitecountry_field.send_keys(sitecountry)577 end578 #If Customer is not linked (Otherwise use Class - Contacts Resource)579 def unlinked_contact_name(unlinkedcontactname)580 wait = Selenium::WebDriver::Wait.new(:timeout => 5)581 wait.until {@driver.find_element(UNLINKED_CONTACT_NAME).displayed?}582 inputfield = @driver.find_element(UNLINKED_CONTACT_NAME)583 inputfield.send_keys(unlinkedcontactname)584 end585 def unlinked_contact_phone(unlinkedcontactphone)586 wait = Selenium::WebDriver::Wait.new(:timeout => 5)587 wait.until {@driver.find_element(UNLINKED_CONTACT_PHONE).displayed?}588 inputfield = @driver.find_element(UNLINKED_CONTACT_PHONE)589 inputfield.send_keys(unlinkedcontactphone)590 end591 def unlinked_contact_email(unlinkedcontactemail)592 wait = Selenium::WebDriver::Wait.new(:timeout => 5)593 wait.until {@driver.find_element(UNLINKED_CONTACT_EMAIL).displayed?}594 inputfield = @driver.find_element(UNLINKED_CONTACT_EMAIL)595 inputfield.send_keys(unlinkedcontactemail)596 end597 #CSS Methods: Popup (Activities Tab)598 def activities_tab()599 wait = Selenium::WebDriver::Wait.new(:timeout => 5)600 wait.until {@driver.find_element(ACTIVITIES_TAB).displayed?}601 activities_tab = @driver.find_element(ACTIVITIES_TAB)602 activities_tab.click603 end604 def search_activity(searchactivity)605 wait = Selenium::WebDriver::Wait.new(:timeout => 5)606 wait.until {@driver.find_element(SEARCH_ACTIVITY).displayed?}607 activity_search = @driver.find_element(SEARCH_ACTIVITY)608 activity_search.send_keys(searchname)609 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)610 wait2.until {@driver.find_element(PATROL_ACTIVITY_SEARCH_BTN).displayed?}611 search_confirm = @driver.find_element(PATROL_ACTIVITY_SEARCH_BTN)612 search_confirm.click613 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)614 wait3.until {@driver.find_element(TOP_ACTIVITY_DESCRIPTION).downcase.include?(searchactivity.downcase)}615 end616 def top_activitydescription()617 top_activitydescription = @driver.find_element(TOP_ACTIVITY_DESCRIPTION)618 end619 #CSS Methods: Popup (Estimates Tab)620 def estimates_tab()621 wait = Selenium::WebDriver::Wait.new(:timeout => 5)622 wait.until {@driver.find_element(ESTIMATES_TAB).displayed?}623 estimates_tab = @driver.find_element(ESTIMATES_TAB)624 estimates_tab.click625 end626 def search_estimate(searchestimate)627 wait = Selenium::WebDriver::Wait.new(:timeout => 5)628 wait.until {@driver.find_element(SEARCH_ESTIMATE).displayed?}629 estimate_search = @driver.find_element(SEARCH_ESTIMATE)630 estimate_search.send_keys(searchestimate)631 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)632 wait2.until {@driver.find_element(PATROL_ESTIMATE_SEARCH_BTN).displayed?}633 search_confirm = @driver.find_element(PATROL_ESTIMATE_SEARCH_BTN)634 search_confirm.click635 end636 #CSS Methods: Popup (Jobs Tab)637 def jobs_tab()638 wait = Selenium::WebDriver::Wait.new(:timeout => 5)639 wait.until {@driver.find_element(JOBS_TAB).displayed?}640 jobs_tab = @driver.find_element(JOBS_TAB)641 jobs_tab.click642 end643 def search_job(searchjob)644 wait = Selenium::WebDriver::Wait.new(:timeout => 5)645 wait.until {@driver.find_element(SEARCH_JOB).displayed?}646 job_search = @driver.find_element(SEARCH_JOB)647 job_search.send_keys(searchjob)648 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)649 wait2.until {@driver.find_element(PATROL_JOB_SEARCH_BTN).displayed?}650 search_confirm = @driver.find_element(PATROL_JOB_SEARCH_BTN)651 search_confirm.click652 end653end...
Class - Contracts Resource.rb
Source:Class - Contracts Resource.rb
...283 def search_contract(searchname)284 wait = Selenium::WebDriver::Wait.new(:timeout => 5)285 wait.until {@driver.find_element(SEARCH_FIELD).displayed?}286 contract_search = @driver.find_element(SEARCH_FIELD)287 contract_search.send_keys(searchname)288 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)289 wait2.until {@driver.find_element(SEARCH_BTN).displayed?}290 search_confirm = @driver.find_element(SEARCH_BTN)291 search_confirm.click292 wait3 = Selenium::WebDriver::Wait.new(:timeout => 10)293 wait3.until {@driver.find_element(TOP_CONTRACT_NAME).text.downcase.include?(searchname.downcase)}294 end295 def search_contractid(searchname)296 i = 0297 loopcount = 5298 loop do299 wait = Selenium::WebDriver::Wait.new(:timeout => 5)300 if301 begin302 wait.until {@driver.find_element(ID_COLUMN).displayed?} == true303 rescue Selenium::WebDriver::Error::StaleElementReferenceError304 false305 end306 break307 if i == loopcount308 raise StaleError309 end310 end311 end312 contract_search = @driver.find_element(ID_COLUMN)313 contract_search.send_keys(searchname)314 @driver.action.send_keys(:enter).perform315 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)316 wait2.until {@driver.find_element(TOP_REFNUMBER).text.include?(searchname)}317 end318 def search_contractid_field()319 field = @driver.find_element(ID_COLUMN)320 end321 def search_contractname(searchname)322 i = 0323 loopcount = 5324 loop do325 wait = Selenium::WebDriver::Wait.new(:timeout => 5)326 if327 begin328 wait.until {@driver.find_element(NAME_COLUMN).displayed?} == true329 rescue Selenium::WebDriver::Error::StaleElementReferenceError330 false331 end332 break333 if i == loopcount334 raise StaleError335 end336 end337 end338 contract_search = @driver.find_element(NAME_COLUMN)339 contract_search.send_keys(searchname)340 @driver.action.send_keys(:enter).perform341 wait2 = Selenium::WebDriver::Wait.new(:timeout => 10)342 wait2.until {@driver.find_element(TOP_CONTRACT_NAME).text.downcase.include?(searchname.downcase)}343 end344 def search_contractname_field()345 field = @driver.find_element(NAME_COLUMN)346 end347 def search_reset()348 currentrecords = @driver.find_element(class: "Counter_Message").text349 wait = Selenium::WebDriver::Wait.new(:timeout => 5)350 wait.until {@driver.find_element(RESET_BTN).displayed?}351 search_reset = @driver.find_element(RESET_BTN)352 search_reset.click353 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)354 wait2.until {@driver.find_element(class: "Counter_Message").text != currentrecords}355 end356 def grid_options()357 wait = Selenium::WebDriver::Wait.new(:timeout => 5)358 wait.until {@driver.find_element(GRID_OPTIONS_DROPDOWN).displayed?}359 grid_options = @driver.find_element(GRID_OPTIONS_DROPDOWN)360 grid_options.click361 end362 def export_contracts()363 wait = Selenium::WebDriver::Wait.new(:timeout => 5)364 wait.until {@driver.find_element(EXPORT_CONTRACTS).displayed?}365 export_customers = @driver.find_element(EXPORT_CONTRACTS)366 export_customers.click367 sleep(2)368 end369 def show_inactives()370 wait = Selenium::WebDriver::Wait.new(:timeout => 5)371 wait.until {@driver.find_element(SHOW_INACTIVES).displayed?}372 show_inactives = @driver.find_element(SHOW_INACTIVES)373 show_inactives.click374 end375 def grid_total()376 gridtotal = @driver.find_element(GRID_TOTAL)377 end378 def resource_performance()379 navigationStart = @driver.execute_script("return window.performance.timing.navigationStart")380 responseStart = @driver.execute_script("return window.performance.timing.responseStart")381 domComplete = @driver.execute_script("return window.performance.timing.domComplete")382 loadPerformance = domComplete - navigationStart383 wait = Selenium::WebDriver::Wait.new(:timeout => 20)384 wait.until {@driver.find_element(class: "Counter_Message").text != "0 records"}385 contacts_records = @driver.find_element(class: "Counter_Message")386 contacts_count = contacts_records.text387 print "Contracts: \n"388 print "%s \n" % contacts_count389 print "Load Time: %s ms \n\n" % loadPerformance390 end391 #CSS Methods: Popup392 def name(contractname)393 contract_name = @driver.find_element(NAME_FIELD)394 contract_name.send_keys(contractname)395 end396 def location(locationselect)397 dropdown_list = @driver.find_element(LOCATION_DROPDOWN)398 options = dropdown_list.find_elements(tag_name: 'option')399 options.each {|option| option.click if option.text == (locationselect)}400 end401 def installment_amount(installmentamount)402 input_field = @driver.find_element(INSTALLMENT_AMOUNT_FIELD)403 input_field.send_keys(installmentamount)404 end405 def customer(customername)406 input_field = @driver.find_element(CUSTOMER_FIELD)407 input_field.send_keys(customername)408 sleep(1)409 @driver.action.send_keys(:enter).perform410 sleep(1)411 end412 def details(detailstext)413 textarea = @driver.find_element(DETAILS_TEXTAREA)414 textarea.send_keys(detailstext)415 end416 def coverages(coveragestext)417 textarea = @driver.find_element(COVERAGES_TEXTAREA)418 textarea.send_keys(coveragestext)419 end420 def special_instructions(specialinstructionstext)421 textarea = @driver.find_element(SPECIAL_INSTRUCTIONS_TEXTAREA)422 textarea.send_keys(specialinstructionstext)423 end424 def start_date(startdate)425 input_field = @driver.find_element(START_DATE_FIELD)426 input_field.send_keys(startdate)427 end428 def end_date(enddate)429 input_field = @driver.find_element(END_DATE_FIELD)430 input_field.send_keys(enddate)431 end432 def closed()433 wait = Selenium::WebDriver::Wait.new(:timeout => 5)434 wait.until {@driver.find_element(CLOSED_CHECKBOX).displayed?}435 checkbox = @driver.find_element(CLOSED_CHECKBOX)436 checkbox.click437 end438 def account_executive(accountexecutive)439 dropdown_list = @driver.find_element(ACCOUNT_EXECUTIVE_DROPDOWN)440 options = dropdown_list.find_elements(tag_name: 'option')441 options.each {|option| option.click if option.text == (accountexecutive)}442 end443 def cancel()444 wait = Selenium::WebDriver::Wait.new(:timeout => 5)445 wait.until {@driver.find_element(CANCEL_BTN).displayed?}446 cancel_popup = @driver.find_element(CANCEL_BTN)447 cancel_popup.click448 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)449 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}450 end451 def actions()452 #Use actions_(action) methods from here453 wait = Selenium::WebDriver::Wait.new(:timeout => 5)454 wait.until {@driver.find_element(ACTIONS_BTN).displayed?}455 actions_popup = @driver.find_element(ACTIONS_BTN)456 actions_popup.click457 end458 def save()459 wait = Selenium::WebDriver::Wait.new(:timeout => 5)460 wait.until {@driver.find_element(SAVE_BTN).enabled?}461 save = @driver.find_element(SAVE_BTN)462 save.click463 end464 def save_close()465 def wait_for()466 Selenium::WebDriver::Wait.new(:timeout => 5).until {yield}467 end468 wait_for {@driver.find_element(SAVE_AND_CLOSE_BTN).enabled?}469 save_and_close = @driver.find_element(SAVE_AND_CLOSE_BTN)470 save_and_close.click471 @driver.switch_to.default_content472 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)473 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}474 end475 #CSS Methods: Popup (Customer Contacts Tab)476 def contacts_tab()477 wait = Selenium::WebDriver::Wait.new(:timeout => 5)478 wait.until {@driver.find_element(CUSTOMER_CONTACTS_TAB).displayed?}479 contacts_tab = @driver.find_element(CUSTOMER_CONTACTS_TAB)480 contacts_tab.click481 end482 #Use Class - Contacts Resource from here483 #CSS Methods: Popup (Jobs Tab)484 def jobs_tab()485 wait = Selenium::WebDriver::Wait.new(:timeout => 5)486 wait.until {@driver.find_element(JOBS_TAB).displayed?}487 jobs_tab = @driver.find_element(JOBS_TAB)488 jobs_tab.click489 end490 def search_job(searchjob)491 wait = Selenium::WebDriver::Wait.new(:timeout => 5)492 wait.until {@driver.find_element(SEARCH_JOB).displayed?}493 job_search = @driver.find_element(SEARCH_JOB)494 job_search.send_keys(searchjob)495 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)496 wait2.until {@driver.find_element(CONTRACT_JOB_SEARCH_BTN).displayed?}497 search_confirm = @driver.find_element(CONTRACT_JOB_SEARCH_BTN)498 search_confirm.click499 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)500 wait3.until {@driver.find_element(TOP_JOB_NAME).downcase.include?(searchjob.downcase)}501 end502 def top_job()503 i = 0504 loopcount = 5505 wait = Selenium::WebDriver::Wait.new(:timeout => 5)506 wait.until {@driver.find_element(TOP_JOB_REFNUMBER).displayed?}507 top_refnumber = @driver.find_element(TOP_JOB_REFNUMBER)508 top_refnumber.click509 loop do510 i += 1511 @driver.switch_to.frame(0)512 begin513 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)514 wait2.until {@driver.find_element(JOB_NAME_FIELD).displayed?}515 rescue Selenium::WebDriver::Error::TimeOutError516 false517 end518 if519 begin520 @driver.find_element(JOB_NAME_FIELD).displayed? == true521 rescue Selenium::WebDriver::Error::NoSuchElementError522 false523 end524 break525 end526 if i == loopcount527 raise FrameError528 end529 end530 end531 def top_jobname()532 top_jobname = @driver.find_element(TOP_JOB_NAME)533 end534 #CSS Methods: Popup (Activities Tab)535 def activities_tab()536 wait = Selenium::WebDriver::Wait.new(:timeout => 5)537 wait.until {@driver.find_element(ACTIVITIES_TAB).displayed?}538 activities_tab = @driver.find_element(ACTIVITIES_TAB)539 activities_tab.click540 end541 def search_activity(searchactivity)542 wait = Selenium::WebDriver::Wait.new(:timeout => 5)543 wait.until {@driver.find_element(SEARCH_ACTIVITY).displayed?}544 activity_search = @driver.find_element(SEARCH_ACTIVITY)545 activity_search.send_keys(searchactivity)546 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)547 wait2.until {@driver.find_element(CONTRACT_ACTIVITY_SEARCH_BTN).displayed?}548 search_confirm = @driver.find_element(CONTRACT_ACTIVITY_SEARCH_BTN)549 search_confirm.click550 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)551 wait3.until {@driver.find_element(TOP_ACTIVITY_DESCRIPTION).downcase.include?(searchactivity.downcase)}552 end553 def top_activity()554 i = 0555 loopcount = 5556 wait = Selenium::WebDriver::Wait.new(:timeout => 5)557 wait.until {@driver.find_element(TOP_ACTIVITY).displayed?}558 top_refnumber = @driver.find_element(TOP_ACTIVITY)559 top_refnumber.click...
Ch_8_Prog_4_Long_Linear_Ruby_Program.rb
Source:Ch_8_Prog_4_Long_Linear_Ruby_Program.rb
...22@driver.find_element(:name, "userName").click23@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='SIGN-ON'])[1]/following::td[1]").click24@driver.find_element(:link, "REGISTER").click25@driver.find_element(:name, "firstName").clear26@driver.find_element(:name, "firstName").send_keys "Selenium"27@driver.find_element(:name, "lastName").clear28@driver.find_element(:name, "lastName").send_keys "User"29@driver.find_element(:name, "phone").clear30@driver.find_element(:name, "phone").send_keys "1234567890"31@driver.find_element(:id, "userName").clear32@driver.find_element(:id, "userName").send_keys "sel@eni.um"33@driver.find_element(:name, "address1").clear34@driver.find_element(:name, "address1").send_keys "1234 5th avenue"35@driver.find_element(:name, "address2").clear36@driver.find_element(:name, "address2").send_keys "sixth street"37@driver.find_element(:name, "city").clear38@driver.find_element(:name, "city").send_keys "denver"39@driver.find_element(:name, "state").clear40@driver.find_element(:name, "state").send_keys "colorado"41@driver.find_element(:name, "postalCode").clear42@driver.find_element(:name, "postalCode").send_keys "80231"43@driver.find_element(:id, "email").clear44@driver.find_element(:id, "email").send_keys "seluser"45@driver.find_element(:name, "password").clear46@driver.find_element(:name, "password").send_keys "seluser"47@driver.find_element(:name, "confirmPassword").clear48@driver.find_element(:name, "confirmPassword").send_keys "seluser"49@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")5051@driver.find_element(:name, "register").click52@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")5354#@driver.find_element(:link, "SIGN-OFF").click55@driver.get "http://newtours.demoaut.com/mercurysignon.php"56@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Password:'])[1]/preceding::td[3]").click57@driver.find_element(:name, "userName").click58@driver.find_element(:name, "userName").clear59@driver.find_element(:name, "userName").send_keys "sel"60@driver.find_element(:name, "userName").send_keys :down61@driver.find_element(:name, "userName").send_keys :down62@driver.find_element(:name, "userName").send_keys :tab63@driver.find_element(:name, "password").clear64@driver.find_element(:name, "password").send_keys "seluser"65@driver.find_element(:xpath, "//div").click66@driver.find_element(:name, "login").click67@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")6869@driver.find_element(:name, "login").click70@driver.find_element(:link, "Home").click71@driver.find_element(:name, "userName").clear72@driver.find_element(:name, "userName").send_keys "seluser"73@driver.find_element(:name, "password").clear74@driver.find_element(:name, "password").send_keys "seluser"75@driver.find_element(:name, "login").click76@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")7778@driver.find_element(:name, "login").click79@driver.find_element(:link, "Flights").click80#@driver.find_element(:name, "toDay").click81#@driver.find_element(:name, "toDay").click82Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "toDay")).select_by(:text, "15")83@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Returning:'])[1]/following::option[27]").click84@driver.find_element(:name, "findFlights").click85@driver.find_element(:name, "reserveFlights").click86@driver.find_element(:name, "passFirst0").click87@driver.find_element(:name, "passFirst0").clear88@driver.find_element(:name, "passFirst0").send_keys "Selenium"89@driver.find_element(:name, "passLast0").clear90@driver.find_element(:name, "passLast0").send_keys "User"91Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.0.meal")).select_by(:text, "Bland")92Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.0.meal")).select_by(:text, "Diabetic")93Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.0.meal")).select_by(:text, "Hindu")94Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.0.meal")).select_by(:text, "Kosher")95Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.0.meal")).select_by(:text, "Low Calorie")96@driver.find_element(:name, "creditnumber").clear97@driver.find_element(:name, "creditnumber").send_keys "1234567890123456"98Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_mn")).select_by(:text, "01")99Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_mn")).select_by(:text, "02")100Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_mn")).select_by(:text, "03")101Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2000")102Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2001")103Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2002")104Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2003")105(close_alert_and_get_its_text()).should == "You have entered 2003 as expiration year!"106@driver.find_element(:name, "cc_exp_dt_yr").click107Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2010")108@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Expiration:'])[1]/following::option[31]").click109@driver.find_element(:name, "cc_frst_name").click110@driver.find_element(:name, "cc_frst_name").clear111@driver.find_element(:name, "cc_frst_name").send_keys "Selenium"112@driver.find_element(:name, "cc_last_name").clear113@driver.find_element(:name, "cc_last_name").send_keys "User"114@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='CONTACT'])[1]/following::table[3]").click115@driver.find_element(:name, "ticketLess").click116@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")117118@driver.find_element(:name, "buyFlights").click119@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")120121@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='CONTACT'])[1]/following::img[3]").click122@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='$584 USD'])[1]/following::img[3]").click123@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Flights'])[1]/following::td[2]").click124@driver.find_element(:link, "Hotels").click125@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='© 2005, Mercury Interactive (v. 011003-1.01-058)'])[1]/preceding::img[1]").click126@driver.find_element(:link, "Car Rentals").click127@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='© 2005, Mercury Interactive (v. 011003-1.01-058)'])[1]/preceding::img[1]").click128@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Shipboard accomodations include: all meals, daily activities and nightly entertainment'])[1]/following::img[1]").click129@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Preferences'])[1]/following::font[3]").click130@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Preferences'])[1]/following::font[3]").click131@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='CONTACT'])[1]/following::table[3]").click132@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Preferences'])[1]/following::font[3]").click133@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")134135@driver.find_element(:name, "findFlights").click136@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")137138@driver.find_element(:name, "reserveFlights").click139@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Cruises'])[1]/following::td[2]").click140@driver.find_element(:link, "Cruises").click141@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='© 2005, Mercury Interactive (v. 011003-1.01-058)'])[1]/preceding::img[1]").click142@driver.find_element(:link, "Cruises").click143@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")144145@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Shipboard accomodations include: all meals, daily activities and nightly entertainment'])[1]/following::img[1]").click146@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Preferences'])[1]/following::font[3]").click147@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Preferences'])[1]/following::font[3]").click148@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Preferences'])[1]/following::td[2]").click149@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Airline:'])[1]/preceding::input[1]").click150@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Airline:'])[1]/preceding::input[2]").click151@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Airline:'])[1]/preceding::input[1]").click152@driver.find_element(:name, "passCount").click153Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "passCount")).select_by(:text, "4")154@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")155156@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Passengers:'])[1]/following::option[4]").click157@driver.find_element(:name, "toDay").click158Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "toDay")).select_by(:text, "19")159@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Returning:'])[1]/following::option[31]").click160@driver.find_element(:name, "fromPort").click161Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "fromPort")).select_by(:text, "New York")162@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Passengers:'])[1]/following::option[8]").click163@driver.find_element(:name, "toPort").click164Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "toPort")).select_by(:text, "Sydney")165@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='On:'])[1]/following::option[52]").click166@driver.find_element(:name, "findFlights").click167@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")168169@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Unified Airlines 363'])[1]/preceding::td[1]").click170@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Unified Airlines 363'])[1]/preceding::td[1]").click171@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Unified Airlines 363'])[1]/preceding::td[1]").click172@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Unified Airlines 363'])[1]/preceding::input[1]").click173@driver.find_element(:name, "results").click174@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")175176@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Unified Airlines 633'])[1]/preceding::td[1]").click177@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Unified Airlines 633'])[1]/preceding::td[1]").click178@driver.find_element(:xpath, "//td").click179@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Unified Airlines 633'])[1]/preceding::input[1]").click180@driver.find_element(:name, "reserveFlights").click181@driver.find_element(:name, "passFirst0").click182@driver.find_element(:name, "passFirst0").clear183@driver.find_element(:name, "passFirst0").send_keys "Selenium"184@driver.find_element(:name, "passLast0").clear185@driver.find_element(:name, "passLast0").send_keys "User"186@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")187188Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.0.meal")).select_by(:text, "Bland")189Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.0.meal")).select_by(:text, "Diabetic")190Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.0.meal")).select_by(:text, "Bland")191@driver.find_element(:name, "passFirst1").clear192@driver.find_element(:name, "passFirst1").send_keys "Sel"193@driver.find_element(:name, "passLast1").clear194@driver.find_element(:name, "passLast1").send_keys "U2"195@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")196197Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.1.meal")).select_by(:text, "Bland")198@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Last Name:'])[2]/following::td[1]").click199Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.1.meal")).select_by(:text, "Diabetic")200@driver.find_element(:name, "passFirst2").clear201@driver.find_element(:name, "passFirst2").send_keys "Sel"202@driver.find_element(:name, "passLast2").clear203@driver.find_element(:name, "passLast2").send_keys "U3"204Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.2.meal")).select_by(:text, "Bland")205Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.2.meal")).select_by(:text, "Diabetic")206Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.2.meal")).select_by(:text, "Hindu")207@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")208209@driver.find_element(:name, "passFirst3").clear210@driver.find_element(:name, "passFirst3").send_keys "Sel"211@driver.find_element(:name, "passLast3").clear212@driver.find_element(:name, "passLast3").send_keys "U4"213Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.3.meal")).select_by(:text, "Bland")214Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.3.meal")).select_by(:text, "Diabetic")215Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.3.meal")).select_by(:text, "Hindu")216Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.3.meal")).select_by(:text, "Kosher")217Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.3.meal")).select_by(:text, "Low Calorie")218Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.2.meal")).select_by(:text, "Kosher")219Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.2.meal")).select_by(:text, "Low Calorie")220Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "pass.2.meal")).select_by(:text, "Low Cholesterol")221@driver.find_element(:name, "creditnumber").clear222@driver.find_element(:name, "creditnumber").send_keys "123"223@driver.find_element(:name, "creditnumber").send_keys :down224@driver.find_element(:name, "creditnumber").send_keys :down225@driver.find_element(:name, "creditnumber").send_keys :down226@driver.find_element(:name, "creditnumber").send_keys :tab227@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")228229Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_mn")).select_by(:text, "01")230Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2000")231Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2001")232Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2002")233Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2003")234(close_alert_and_get_its_text()).should == "You have entered 2003 as expiration year!"235Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2004")236Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2005")237Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2006")238Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2007")239Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2008")240Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2009")241Selenium::WebDriver::Support::Select.new(@driver.find_element(:name, "cc_exp_dt_yr")).select_by(:text, "2010")242@driver.find_element(:name, "cc_frst_name").clear243@driver.find_element(:name, "cc_frst_name").send_keys "Selenium"244@driver.find_element(:name, "cc_last_name").clear245@driver.find_element(:name, "cc_last_name").send_keys "User"246@driver.find_element(:name, "ticketLess").click247@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Delivery Address'])[1]/following::input[1]").click248@driver.find_element(:name, "buyFlights").click249@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='CONTACT'])[1]/following::img[3]").click250@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Vacations'])[1]/following::u[1]").click251@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Vacations'])[1]/following::u[1]").click252@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Use Java Version'])[1]/following::img[1]").click253@driver.find_element(:link, "SUPPORT").click254@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='CONTACT'])[1]/following::td[7]").click255@driver.find_element(:xpath, "(.//*[normalize-space(text()) and normalize-space(.)='Cruises'])[1]/following::td[2]").click256@driver.find_element(:xpath, "//td/table/tbody/tr/td/table/tbody/tr/td/table").click257@driver.find_element(:link, "Vacations").click258@driver.find_element(:xpath, "//td/table/tbody/tr/td/table/tbody/tr/td").click259@driver.save_screenshot("./#{Time.now.strftime("failshot__%d_%m_%Y__%H_%M_%S")}.png")
...
selenium_search.rb
Source:selenium_search.rb
...4wait = Selenium::WebDriver::Wait.new(:timeout => 10)5wait.until { driver.find_element :id => "search" }6element= driver.find_element :id => "search"7sleep(1)8element.send_keys "B"9element.send_keys "Y"10element.send_keys "U"11element.send_keys " "12element.send_keys "v"13element.send_keys "s"14element.send_keys " "15element.send_keys "U"16element.send_keys " "17element.send_keys "o"18element.send_keys "f"19element.send_keys " "20element.send_keys "U"21driver.find_element(:class => "circle-arrow").click22wait = Selenium::WebDriver::Wait.new(:timeout => 10)23wait.until { driver.find_element :id => "center" }24sleep(5)25driver.find_element(:link_text => "HOME").click26wait = Selenium::WebDriver::Wait.new(:timeout => 10)27wait.until { driver.find_element :id => "search" }28element= driver.find_element :id => "search"29element.send_keys "Salt Lake City"30element.send_keys " and "31element.send_keys "Seattle, WA"32wait = Selenium::WebDriver::Wait.new(:timeout => 10)33wait.until { driver.find_element :id => "center" }34driver.find_element(:link_text => "COST OF LIVING").click35sleep(5)36driver.quit...
send_keys
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Selenium"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys :control, 'a'4driver.find_element(:name, 'btnG').click
send_keys
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "selenium"2driver.find_element(:name, 'btnG').click3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')6element = driver.find_element(:name, 'q')7element = driver.find_element(:name, 'q')8element = driver.find_element(:name, 'q')
send_keys
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys("Selenium WebDriver")2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys("Selenium WebDriver")4driver.find_element(:name, 'btnG').click5driver.find_element(:name, 'q').send_keys("Selenium WebDriver")6driver.find_element(:name, 'btnG').click7driver.find_element(:name, 'q').send_keys("Selenium WebDriver")8driver.find_element(:name, 'btnG').click9driver.find_element(:name, 'q').send_keys("Selenium WebDriver")10driver.find_element(:name, 'btnG').click11driver.find_element(:name, 'q').send_keys("Selenium WebDriver")12driver.find_element(:name, 'btnG').click13driver.find_element(:name
send_keys
Using AI Code Generation
1search_box = driver.find_element(name: 'q')2wait = Selenium::WebDriver::Wait.new(timeout: 10)3wait.until { driver.title.downcase.start_with? 'selenium webdriver' }4search_box = driver.find_element(name: 'q')5wait = Selenium::WebDriver::Wait.new(timeout: 30)6wait.until { driver.title.downcase.start_with? 'selenium webdriver' }7search_box = driver.find_element(name: 'q')8wait = Selenium::WebDriver::Wait.new(timeout: 10)9wait.until { driver.title.downcase.start_with? 'selenium webdriver' }10search_box = driver.find_element(name: 'q')11wait = Selenium::WebDriver::Wait.new(timeout: 10)12wait.until { driver.title.downcase.start_with? 'selenium webdriver' }13search_box = driver.find_element(name: 'q')
send_keys
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Hello World"2element.send_keys(keys)3element.send_keys(keys)4element.send_keys(keys)5element.send_keys(keys)6element.send_keys(keys)7element.send_keys(keys)8element.send_keys(keys)
send_keys
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys "Selenium"2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys :control, 'a'4driver.find_element(:name, 'btnG').click
send_keys
Using AI Code Generation
1driver.find_element(:name, 'q').send_keys("Selenium WebDriver")2driver.find_element(:name, 'btnG').click3driver.find_element(:name, 'q').send_keys("Selenium WebDriver")4driver.find_element(:name, 'btnG').click5driver.find_element(:name, 'q').send_keys("Selenium WebDriver")6driver.find_element(:name, 'btnG').click7driver.find_element(:name, 'q').send_keys("Selenium WebDriver")8driver.find_element(:name, 'btnG').click9driver.find_element(:name, 'q').send_keys("Selenium WebDriver")10driver.find_element(:name, 'btnG').click11driver.find_element(:name, 'q').send_keys("Selenium WebDriver")12driver.find_element(:name, 'btnG').click13driver.find_element(:name
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!