How to use frame method of Selenium.WebDriver Package

Best Selenium code snippet using Selenium.WebDriver.frame

Class - Invoices Resource.rb

Source:Class - Invoices Resource.rb Github

copy

Full Screen

...85 TOP_ACTIVITY_DESCRIPTION = {xpath: "/html/body/form/div[3]/div[1]/div[2]/div[4]/div/div[3]/table/tbody/tr/td[5]"}86 INVOICE_ACTIVITY_SEARCH_BTN = {css: "input[id$='InvoiceSearchActivities']"}87 INVOICE_ACTIVITY_RESET_BTN = {css: "input[id$='InvoiceResetActivities']"}88 #CSS Selectors: Frame Anchors89 FRAME = {css: "iframe[tabindex='0']"}90 ACTIVITY_REASON_DROPDOWN = {css: "select[id$='ActivityReasonCombobox']"}91 DOCUMENTS_SHOWHIDE_UPLOADER = {xpath: "/html/body/form/div[3]/div[1]/div/div/div[1]/div[2]/a/span"}92 PRINTEMAIL_PDF_CHECKBOX = {css: "input[id$='AttachPDFInput']"}93 JOB_NAME_FIELD = {css: "input[id$='Job_Name']"}94 CUSTOMER_NAME_FIELD = {css: "input[id$='Customer_Name']"}95 #AJAX Buffer96 AJAX = {css: "div[class='Feedback_AjaxWait']"}97 #Custom Errors98 class FrameError < StandardError99 def initialize(msg='Unable to switch to frame and locate element')100 super101 end102 end103 class StaleError < StandardError104 def initialize(msg='Stale reference error')105 super106 end107 end108 attr_reader :driver109 def initialize(driver)110 @driver = driver111 end112 #CSS Modifiers: Grid113 def open_invoices()114 i = 0115 loopcount = 5116 loop do117 i += 1118 begin119 wait = Selenium::WebDriver::Wait.new(:timeout => 10)120 wait.until {@driver.find_element(INVOICES_OPTN).displayed?}121 rescue Selenium::WebDriver::Error::StaleElementReferenceError122 false123 end124 if @driver.find_element(INVOICES_OPTN).displayed? == true125 break126 end127 if i == loopcount128 raise StaleError129 end130 end131 invoices_button = @driver.find_element(INVOICES_OPTN)132 invoices_button.click133 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)134 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}135 #wait2.until {@driver.find_element(class: "Counter_Message").text != "0 records" }136 end137 def create_invoice()138 i = 0139 loopcount = 5140 wait = Selenium::WebDriver::Wait.new(:timeout => 5)141 wait.until {@driver.find_element(CREATE_INVOICE_BTN).displayed?}142 create_invoice_button = @driver.find_element(CREATE_INVOICE_BTN)143 create_invoice_button.click144 #sleep(3)145 #def wait_for2()146 # Selenium::WebDriver::Wait.new(:timeout => 10).until { yield }147 #end148 #wait_for2 {@driver.find_element(id:"os-internal-ui-dialog-title-1").displayed?}149 #sleep(2)150 #@driver.switch_to.frame(0)151 loop do152 i += 1153 @driver.switch_to.frame(0)154 begin155 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)156 wait2.until {@driver.find_element(JOB_SEARCH_FIELD).displayed?}157 rescue Selenium::WebDriver::Error::TimeoutError158 false159 end160 if161 begin162 @driver.find_element(JOB_SEARCH_FIELD).displayed? == true163 rescue Selenium::WebDriver::Error::NoSuchElementError164 false165 end166 break167 end168 if i == loopcount169 raise FrameError170 end171 end172 end173 def select_job(selectjob)174 i = 0175 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.click903 loop do904 i += 1905 @driver.switch_to.frame(0)906 begin907 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)908 wait2.until {@driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed?}909 rescue Selenium::WebDriver::Error::TimeOutError910 false911 end912 if913 begin914 @driver.find_element(ACTIVITY_REASON_DROPDOWN).displayed? == true915 rescue Selenium::WebDriver::Error::NoSuchElementError916 false917 end918 break919 end...

Full Screen

Full Screen

Class - Estimates Resource.rb

Source:Class - Estimates Resource.rb Github

copy

Full Screen

...85 TOP_JOB = {css: "a[id$='ctl03_wtJobIdLink']"}86 ESTIMATE_JOB_SEARCH_BTN = {css: "input[id$='EstimateSearchJobs']"}87 ESTIMATE_JOB_RESET_BTN = {css: "input[id$='EstimateResetJobs']"}88 #CSS Selectors: Frame Anchors89 FRAME = {css: "iframe[tabindex='0']"}90 ACTIVITY_REASON_DROPDOWN = {css: "select[id$='ActivityReasonCombobox']"}91 INVOICE_PONUMBER_FIELD = {css: "input[id$='Invoice_PONumber']"}92 DOCUMENTS_SHOWHIDE_UPLOADER = {xpath: "/html/body/form/div[3]/div[1]/div/div/div[1]/div[2]/a/span"}93 PRINTEMAIL_PDF_CHECKBOX = {css: "input[id$='AttachPDFInput']"}94 #Custom Errors95 class FrameError < StandardError96 def initialize(msg='Unable to switch to frame and locate element')97 super98 end99 end100 class StaleError < StandardError101 def initialize(msg='Stale reference error')102 super103 end104 end105 attr_reader :driver106 def initialize(driver)107 @driver = driver108 end109 #CSS Methods: Grid110 def open_estimates()111 i = 0112 loopcount = 5113 loop do114 i += 1115 begin116 wait = Selenium::WebDriver::Wait.new(:timeout => 10)117 wait.until {@driver.find_element(ESTIMATES_OPTN).displayed?}118 rescue Selenium::WebDriver::Error::StaleElementReferenceError119 false120 end121 if @driver.find_element(ESTIMATES_OPTN).displayed? == true122 break123 end124 if i == loopcount125 raise StaleError126 end127 end128 estimates_button = @driver.find_element(ESTIMATES_OPTN)129 estimates_button.click130 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)131 wait2.until {@driver.find_element(TOP_REFNUMBER).displayed?}132 end133 def create_estimate()134 i = 0135 loopcount = 5136 wait = Selenium::WebDriver::Wait.new(:timeout => 5)137 wait.until {@driver.find_element(CREATE_ESTIMATE_BTN).displayed?}138 create_esimate_button = @driver.find_element(CREATE_ESTIMATE_BTN)139 create_esimate_button.click140 loop do141 i += 1142 @driver.switch_to.frame(0)143 begin144 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)145 wait2.until {@driver.find_element(CUSTOMER_SEARCH_FIELD).displayed?}146 rescue Selenium::WebDriver::Error::TimeoutError147 false148 end149 if150 begin151 @driver.find_element(CUSTOMER_SEARCH_FIELD).displayed? == true152 rescue Selenium::WebDriver::Error::NoSuchElementError153 false154 end155 break156 end157 if i == loopcount158 raise FrameError159 end160 end161 end162 def select_customer(selectcustomer)163 i = 0164 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.click806 loop do807 i += 1808 @driver.switch_to.frame(0)809 begin810 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)811 wait2.until {@driver.find_element(INVOICE_PONUMBER_FIELD).displayed?}812 rescue Selenium::WebDriver::Error::TimeoutError813 false814 end815 if816 begin817 @driver.find_element(INVOICE_PONUMBER_FIELD).displayed? == true818 rescue Selenium::WebDriver::Error::NoSuchElementError819 false820 end821 break822 end...

Full Screen

Full Screen

Class - Contacts Resource.rb

Source:Class - Contacts Resource.rb Github

copy

Full Screen

...62 #CANCEL_LINK_BTN = {css: "input[value='Cancel']"}63 #CONFIRM_LINK_BTN = {css: "input[value='Link']"}64 #Custom Errors65 class FrameError < StandardError66 def initialize(msg='Unable to switch to frame and locate element')67 super68 end69 end70 class StaleError < StandardError71 def initialize(msg='Stale reference error')72 super73 end74 end75 class TestError < StandardError76 def initialize(msg='Test Error')77 super78 end79 end80 attr_reader :driver81 def initialize(driver)82 @driver = driver83 end84 #Class Methods: Grid85 def create_contact()86 i = 087 loopcount = 588 wait = Selenium::WebDriver::Wait.new(:timeout => 5)89 wait.until {@driver.find_element(CREATE_CONTACT_BTN).displayed?}90 create_contact = @driver.find_element(CREATE_CONTACT_BTN)91 create_contact.click92 loop do93 i += 194 @driver.switch_to.frame(0)95 begin96 wait3 = Selenium::WebDriver::Wait.new(:timeout => 2)97 wait3.until {@driver.find_element(CONTACT_NAME_FIELD).displayed?}98 rescue Selenium::WebDriver::Error::TimeOutError99 false100 end101 if102 begin103 @driver.find_element(CONTACT_NAME_FIELD).displayed? == true104 rescue Selenium::WebDriver::Error::NoSuchElementError105 false106 end107 break108 end109 if i == loopcount110 raise FrameError111 end112 end113 end114 def top()115 top_contact = @driver.find_element(TOP_CONTACT)116 end117 def top_refnumber()118 top_refnumber = @driver.find_element(TOP_REFNUMBER)119 end120 def top_description()121 top_description = @driver.find_element(TOP_DESCRIPTION)122 end123 def top_open()124 i = 0125 loopcount = 5126 top_refnumber = @driver.find_element(TOP_REFNUMBER)127 top_refnumber.click128 loop do129 i += 1130 @driver.switch_to.frame(0)131 begin132 wait3 = Selenium::WebDriver::Wait.new(:timeout => 2)133 wait3.until {@driver.find_element(CONTACT_NAME_FIELD).displayed?}134 rescue Selenium::WebDriver::Error::TimeOutError135 false136 end137 if138 begin139 @driver.find_element(CONTACT_NAME_FIELD).displayed? == true140 rescue Selenium::WebDriver::Error::NoSuchElementError141 false142 end143 break144 end145 if i == loopcount146 raise FrameError147 end148 end149 end150 def top_actions()151 top_contactactions = @driver.find_element(TOP_CONTACT_ACTIONS)152 top_contactactions.click153 end154 def actions_documents()155 wait = Selenium::WebDriver::Wait.new(:timeout => 5)156 wait.until {@driver.find_element(TOP_CONTACT_DOCUMENTS).displayed?}157 top_documents = @driver.find_element(TOP_CONTACT_DOCUMENTS)158 top_documents.click159 end160 def actions_makeinactive()161 currenttopref = @driver.find_element(TOP_REFNUMBER).text162 wait = Selenium::WebDriver::Wait.new(:timeout => 5)163 wait.until {@driver.find_element(TOP_CONTACT_INACTIVE).displayed?}164 top_makeinactive = @driver.find_element(TOP_CONTACT_INACTIVE)165 top_makeinactive.click166 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)167 wait2.until {@driver.find_element(PUSH_CONFIRM).displayed?}168 confirm = @driver.find_element(PUSH_CONFIRM)169 confirm.click170 wait3 = Selenium::WebDriver::Wait.new(:timeout => 5)171 wait3.until {@driver.find_element(TOP_REFNUMBER).text != currenttopref}172 end173 def search_contact(searchname)174 wait = Selenium::WebDriver::Wait.new(:timeout => 5)175 wait.until {@driver.find_element(SEARCH_FIELD).displayed?}176 contact_name = @driver.find_element(SEARCH_FIELD)177 contact_name.send_keys(searchname)178 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)179 wait2.until {@driver.find_element(SEARCH_BTN).displayed?}180 search_confirm = @driver.find_element(SEARCH_BTN)181 search_confirm.click182 wait3 = Selenium::WebDriver::Wait.new(:timeout => 10)183 wait3.until {(top_refnumber = @driver.find_element(TOP_REFNUMBER).text + top_contact = @driver.find_element(TOP_CONTACT).text.downcase + @driver.find_element(TOP_DESCRIPTION).text.downcase).include?(searchname)}184 end185 def search_reset()186 wait = Selenium::WebDriver::Wait.new(:timeout => 5)187 wait.until {@driver.find_element(RESET_BTN).displayed?}188 search_reset = @driver.find_element(RESET_BTN)189 search_reset.click190 end191 def grid_options()192 wait = Selenium::WebDriver::Wait.new(:timeout => 5)193 wait.until {@driver.find_element(GRID_OPTIONS_DROPDOWN).displayed?}194 grid_options = @driver.find_element(GRID_OPTIONS_DROPDOWN)195 grid_options.click196 end197 def export_contacts()198 wait = Selenium::WebDriver::Wait.new(:timeout => 5)199 wait.until {@driver.find_element(EXPORT_CONTACTS).displayed?}200 export_contacts = @driver.find_element(EXPORT_CONTACTS)201 export_contacts.click202 sleep(2)203 end204 def find_duplicates()205 wait = Selenium::WebDriver::Wait.new(:timeout => 5)206 wait.until {@driver.find_element(FIND_DUPLICATES).displayed?}207 find_duplicates = @driver.find_element(FIND_DUPLICATES)208 find_duplicates.click209 end210 def show_inactives()211 wait = Selenium::WebDriver::Wait.new(:timeout => 5)212 wait.until {@driver.find_element(SHOW_INACTIVES_CHECKBOX).displayed?}213 show_inactives = @driver.find_element(SHOW_INACTIVES_CHECKBOX)214 show_inactives.click215 end216 def resource_performance()217 navigationStart = @driver.execute_script("return window.performance.timing.navigationStart")218 responseStart = @driver.execute_script("return window.performance.timing.responseStart")219 domComplete = @driver.execute_script("return window.performance.timing.domComplete")220 loadPerformance = domComplete - navigationStart221 wait = Selenium::WebDriver::Wait.new(:timeout => 20)222 wait.until {@driver.find_element(GRID_TOTAL).text != "0 records"}223 contacts_records = @driver.find_element(GRID_TOTAL)224 contacts_count = contacts_records.text225 print "Contacts: \n"226 print "%s \n" % contacts_count227 print "Load Time: %s ms \n\n" % loadPerformance228 end229 #Class Methods: Popup230 def contact_name(contactname)231 wait = Selenium::WebDriver::Wait.new(:timeout => 5)232 wait.until {@driver.find_element(CONTACT_NAME_FIELD).displayed?}233 contact_name = @driver.find_element(CONTACT_NAME_FIELD)234 contact_name.send_keys(contactname)235 end236 def add_phone()237 wait = Selenium::WebDriver::Wait.new(:timeout => 5)238 wait.until {@driver.find_element(ADD_PHONE_OPTN).displayed?}239 add_phone = @driver.find_element(ADD_PHONE_OPTN)240 add_phone.click241 end242 def contact_phone1(contactphone1)243 wait = Selenium::WebDriver::Wait.new(:timeout => 5)244 wait.until {@driver.find_element(CONTACT_PHONE_FIRST).displayed?}245 phone_field = @driver.find_element(CONTACT_PHONE_FIRST)246 phone_field.send_keys(contactphone1)247 end248 def contact_phone2(contactphone2)249 wait = Selenium::WebDriver::Wait.new(:timeout => 5)250 wait.until {@driver.find_element(CONTACT_PHONE_SECOND).displayed?}251 phone_field = @driver.find_element(CONTACT_PHONE_SECOND)252 phone_field.send_keys(contactphone2)253 end254 def contact_phone3(contactphone3)255 wait = Selenium::WebDriver::Wait.new(:timeout => 5)256 wait.until {@driver.find_element(CONTACT_PHONE_THIRD).displayed?}257 phone_field = @driver.find_element(CONTACT_PHONE_THIRD)258 phone_field.send_keys(contactphone3)259 end260 def add_email261 wait = Selenium::WebDriver::Wait.new(:timeout => 5)262 wait.until {@driver.find_element(ADD_EMAIL_OPTN).displayed?}263 add_email = @driver.find_element(ADD_EMAIL_OPTN)264 add_email.click265 end266 def contact_email1(contactemail1)267 wait = Selenium::WebDriver::Wait.new(:timeout => 5)268 wait.until {@driver.find_element(CONTACT_EMAIL_FIRST).displayed?}269 email_field = @driver.find_element(CONTACT_EMAIL_FIRST)270 email_field.send_keys(contactemail1)271 end272 def contact_email2(contactemail2)273 wait = Selenium::WebDriver::Wait.new(:timeout => 5)274 wait.until {@driver.find_element(CONTACT_EMAIL_SECOND).displayed?}275 email_field = @driver.find_element(CONTACT_EMAIL_SECOND)276 email_field.send_keys(contactemail2)277 end278 def contact_email3(contactemail3)279 wait = Selenium::WebDriver::Wait.new(:timeout => 5)280 wait.until {@driver.find_element(CONTACT_EMAIL_THIRD).displayed?}281 email_field = @driver.find_element(CONTACT_EMAIL_THIRD)282 email_field.send_keys(contactemail3)283 end284 def contact_notes(contactnotes)285 wait = Selenium::WebDriver::Wait.new(:timeout => 5)286 wait.until {@driver.find_element(CONTACT_NOTES_FIELD).displayed?}287 contact_notes = @driver.find_element(CONTACT_NOTES_FIELD)288 contact_notes.send_keys(contactnotes)289 end290 def cancel()291 wait = Selenium::WebDriver::Wait.new(:timeout => 5)292 wait.until {@driver.find_element(CANCEL_BTN).displayed?}293 cancel_popup = @driver.find_element(CANCEL_BTN)294 cancel_popup.click295 end296 def actions()297 wait = Selenium::WebDriver::Wait.new(:timeout => 5)298 wait.until {@driver.find_element(ACTIONS_BTN).displayed?}299 actions_popup = @driver.find_element(ACTIONS_BTN)300 actions_popup.click301 end302 def inactive_popup303 wait = Selenium::WebDriver::Wait.new(:timeout => 5)304 wait.until {@driver.find_element(POPUP_INACTIVE).displayed?}305 inactive_popup = @driver.find_element(POPUP_INACTIVE)306 inactive_popup.click307 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)308 wait2.until {@driver.find_element(POPUP_CONFIRM_INACTIVE).displayed?}309 confirm_inactive = @driver.find_element(POPUP_CONFIRM_INACTIVE)310 confirm_inactive.click311 end312 def save_close()313 i = 0314 loopcount = 5315 f = 0316 frameloopcount = 10317 wait = Selenium::WebDriver::Wait.new(:timeout => 5)318 wait.until {@driver.find_element(SAVE_AND_CLOSE_BTN).displayed?}319 save_and_close = @driver.find_element(SAVE_AND_CLOSE_BTN)320 save_and_close.click321 @driver.switch_to.default_content322 end323 def save_close_popup()324 i = 0325 loopcount = 5326 f = 0327 frameloopcount = 10328 wait = Selenium::WebDriver::Wait.new(:timeout => 5)329 wait.until {@driver.find_element(SAVE_AND_CLOSE_BTN).displayed?}330 save_and_close = @driver.find_element(SAVE_AND_CLOSE_BTN)331 save_and_close.click332 sleep(1)333 @driver.switch_to.default_content334 sleep(1)335 @driver.switch_to.frame(0)336 end337 def save_close_grid()338 wait = Selenium::WebDriver::Wait.new(:timeout => 5)339 wait.until {@driver.find_element(SAVE_AND_CLOSE_BTN).displayed?}340 save_and_close = @driver.find_element(SAVE_AND_CLOSE_BTN)341 save_and_close.click342 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)343 wait2.until {@driver.find_element(class: "Counter_Message").text != "0 records"}344 end345 #CSS Modifiers: Contacts Section (Resource Popups)346 def search_contacts_tab(searchname)347 wait = Selenium::WebDriver::Wait.new(:timeout => 5)348 wait.until {@driver.find_element(CONTACTS_SEARCH_FIELD).displayed?}349 contact_name = @driver.find_element(CONTACTS_SEARCH_FIELD)350 contact_name.send_keys(searchname)351 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)352 wait2.until {@driver.find_element(CONTACTS_SEARCH_FIELD)['value'] == searchname}353 button = @driver.find_element(SEARCH_CONTACTS_BTN)354 button.click355 end356 def reset_contacts_search()357 button = @driver.find_element(RESET_CONTACTS_BTN)358 button.click359 end360 def show_inactive_contacts()361 wait = Selenium::WebDriver::Wait.new(:timeout => 5)362 wait.until {@driver.find_element(SHOW_INACTIVE_CONTACTS).displayed?}363 top_makeinactive = @driver.find_element(SHOW_INACTIVE_CONTACTS)364 top_makeinactive.click365 end366 def create_new_button()367 i = 0368 loopcount = 5369 f = 0370 frameloopcount = 10371 wait = Selenium::WebDriver::Wait.new(:timeout => 5)372 wait.until {@driver.find_element(CREATE_NEW_BTN).displayed?}373 button = @driver.find_element(CREATE_NEW_BTN)374 button.click375 loop do376 i += 1377 loop do378 f += 1379 begin380 @driver.switch_to.frame(1)381 rescue Selenium::WebDriver::Error::NoSuchFrameError382 false383 end384 break385 if f == frameloopcount386 raise FrameError387 end388 end389 begin390 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)391 wait2.until {@driver.find_element(CONTACT_NAME_FIELD).displayed?}392 rescue Selenium::WebDriver::Error::TimeoutError393 false394 end395 if396 begin397 @driver.find_element(CONTACT_NAME_FIELD).displayed? == true398 rescue Selenium::WebDriver::Error::NoSuchElementError399 false400 end401 break402 end403 if i == loopcount404 raise TestError405 end406 end407 end408 def link_existing_button()409 i = 0410 loopcount = 5411 wait = Selenium::WebDriver::Wait.new(:timeout => 5)412 wait.until {@driver.find_element(LINK_EXISTING_BTN).displayed?}413 button = @driver.find_element(LINK_EXISTING_BTN)414 button.click415 loop do416 i += 1417 @driver.switch_to.frame(1)418 begin419 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)420 wait2.until {@driver.find_element(LINK_CONTACT_SEARCH).displayed?}421 rescue Selenium::WebDriver::Error::TimeOutError422 false423 end424 if425 begin426 @driver.find_element(LINK_CONTACT_SEARCH_NAME).displayed? == true427 rescue Selenium::WebDriver::Error::NoSuchElementError428 false429 end430 break431 end432 if i == loopcount433 raise FrameError434 end435 end436 end437 def first_contact_name()438 display = @driver.find_element(FIRST_CONTACT_NAME)439 end440 def first_contact_notes()441 display = @driver.find_element(FIRST_CONTACT_NOTES)442 end443 def first_billing_checkbox()444 wait = Selenium::WebDriver::Wait.new(:timeout => 5)445 wait.until {@driver.find_element(FIRST_BILLING_CHKBX).displayed?}446 checkbox = @driver.find_element(FIRST_BILLING_CHKBX)447 checkbox.click448 sleep(1)449 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)450 wait2.until {@driver.find_element(FIRST_BILLING_CHKBX).selected?}451 end452 def first_site_checkbox()453 wait = Selenium::WebDriver::Wait.new(:timeout => 5)454 wait.until {@driver.find_element(FIRST_SITE_CHKBX).displayed?}455 checkbox = @driver.find_element(FIRST_SITE_CHKBX)456 checkbox.click457 sleep(1)458 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)459 wait2.until {@driver.find_element(FIRST_SITE_CHKBX).selected?}460 end461 def second_contact_name()462 display = @driver.find_element(SECOND_CONTACT_NAME)463 end464 def second_contact_notes()465 display = @driver.find_element(SECOND_CONTACT_NOTES)466 end467 def second_billing_checkbox()468 wait = Selenium::WebDriver::Wait.new(:timeout => 5)469 wait.until {@driver.find_element(SECOND_BILLING_CHKBX).displayed?}470 checkbox = @driver.find_element(SECOND_BILLING_CHKBX)471 checkbox.click472 sleep(1)473 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)474 wait2.until {@driver.find_element(SECOND_BILLING_CHKBX).selected?}475 end476 def second_site_checkbox()477 wait = Selenium::WebDriver::Wait.new(:timeout => 5)478 wait.until {@driver.find_element(SECOND_SITE_CHKBX).displayed?}479 checkbox = @driver.find_element(SECOND_SITE_CHKBX)480 checkbox.click481 sleep(1)482 wait2 = Selenium::WebDriver::Wait.new(:timeout => 5)483 wait2.until {@driver.find_element(SECOND_SITE_CHKBX).selected?}484 end485 def remove_top_contact()486 wait = Selenium::WebDriver::Wait.new(:timeout => 5)487 wait.until {@driver.find_element(REMOVE_TOP_CONTACT).displayed?}488 button = @driver.find_element(REMOVE_TOP_CONTACT)489 button.click490 end491 #CSS Modifiers: Link Contact Popup492 def link_contact(searchname)493 i = 0494 loopcount = 5495 f = 0496 frameloopcount = 10497 wait = Selenium::WebDriver::Wait.new(:timeout => 5)498 wait.until {@driver.find_element(LINK_CONTACT_SEARCH_NAME).displayed?}499 contact_name = @driver.find_element(LINK_CONTACT_SEARCH_NAME)500 contact_name.send_keys(searchname)501 sleep(1)502 @driver.action.send_keys(:enter).perform503 button = @driver.find_element(LINK_TOP_CONTACT_LINK)504 button.click505 sleep(1)506 loop do507 i += 1508 loop do509 f += 1510 begin511 @driver.switch_to.default_content512 @driver.switch_to.frame(0)513 rescue Selenium::WebDriver::Error::NoSuchFrameError514 false515 end516 break517 if f == frameloopcount518 raise FrameError519 end520 end521 begin522 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)523 wait2.until {@driver.find_element(FIRST_CONTACT_NAME).displayed?}524 rescue Selenium::WebDriver::Error::TimeOutError525 false526 end527 if528 begin529 @driver.find_element(FIRST_CONTACT_NAME).displayed? == true530 rescue Selenium::WebDriver::Error::NoSuchElementError531 false532 end533 break534 end535 if i == loopcount536 raise FrameError537 end538 end539 end540 def cancel_link_contact()541 i = 0542 loopcount = 5543 wait = Selenium::WebDriver::Wait.new(:timeout => 5)544 wait.until {@driver.find_element(CANCEL_LINK_BTN).displayed?}545 button = @driver.find_element(CANCEL_LINK_BTN)546 button.click547 loop do548 i += 1549 begin550 @driver.switch_to.frame(0)551 rescue552 Selenium::WebDriver::Error::NoSuchFrameError553 end554 begin555 wait2 = Selenium::WebDriver::Wait.new(:timeout => 2)556 wait2.until {@driver.find_element(SAVE_AND_CLOSE_BTN).displayed?}557 rescue Selenium::WebDriver::Error::TimeOutError558 false559 end560 if561 begin562 @driver.find_element(SAVE_AND_CLOSE_BTN).displayed? == true563 rescue Selenium::WebDriver::Error::NoSuchElementError564 false...

Full Screen

Full Screen

driver.rb

Source:driver.rb Github

copy

Full Screen

...78 self.class.load_selenium79 @app = app80 @browser = nil81 @exit_status = nil82 @frame_handles = Hash.new { |hash, handle| hash[handle] = [] }83 @options = DEFAULT_OPTIONS.merge(options)84 @node_class = ::Capybara::Selenium::Node85 end86 def visit(path)87 browser.navigate.to(path)88 end89 def refresh90 browser.navigate.refresh91 end92 def go_back93 browser.navigate.back94 end95 def go_forward96 browser.navigate.forward97 end98 def html99 browser.page_source100 rescue Selenium::WebDriver::Error::JavascriptError => e101 raise unless e.message.include?('documentElement is null')102 end103 def title104 browser.title105 end106 def current_url107 browser.current_url108 end109 def wait?; true; end110 def needs_server?; true; end111 def execute_script(script, *args)112 browser.execute_script(script, *native_args(args))113 end114 def evaluate_script(script, *args)115 result = execute_script("return #{script}", *args)116 unwrap_script_result(result)117 end118 def evaluate_async_script(script, *args)119 browser.manage.timeouts.script_timeout = Capybara.default_max_wait_time120 result = browser.execute_async_script(script, *native_args(args))121 unwrap_script_result(result)122 end123 def send_keys(*args)124 active_element.send_keys(*args)125 end126 def save_screenshot(path, **_options)127 browser.save_screenshot(path)128 end129 def reset!130 # Use instance variable directly so we avoid starting the browser just to reset the session131 return unless @browser132 navigated = false133 timer = Capybara::Helpers.timer(expire_in: 10)134 begin135 # Only trigger a navigation if we haven't done it already, otherwise it136 # can trigger an endless series of unload modals137 reset_browser_state unless navigated138 navigated = true139 # Ensure the page is empty and trigger an UnhandledAlertError for any modals that appear during unload140 wait_for_empty_page(timer)141 rescue *unhandled_alert_errors142 # This error is thrown if an unhandled alert is on the page143 # Firefox appears to automatically dismiss this alert, chrome does not144 # We'll try to accept it145 accept_unhandled_reset_alert146 # try cleaning up the browser again147 retry148 end149 end150 def frame_obscured_at?(x:, y:)151 frame = @frame_handles[current_window_handle].last152 return false unless frame153 switch_to_frame(:parent)154 begin155 frame.base.obscured?(x: x, y: y)156 ensure157 switch_to_frame(frame)158 end159 end160 def switch_to_frame(frame)161 handles = @frame_handles[current_window_handle]162 case frame163 when :top164 handles.clear165 browser.switch_to.default_content166 when :parent167 handles.pop168 browser.switch_to.parent_frame169 else170 handles << frame171 browser.switch_to.frame(frame.native)172 end173 end174 def current_window_handle175 browser.window_handle176 end177 def window_size(handle)178 within_given_window(handle) do179 size = browser.manage.window.size180 [size.width, size.height]181 end182 end183 def resize_window_to(handle, width, height)184 within_given_window(handle) do185 browser.manage.window.resize_to(width, height)...

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

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').click

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1driver.switch_to.frame("frame_name")2driver.find_element(:link_text, "link_text").click3driver.find_element(:tag_name, "iframe").click4driver.switch_to.frame("frame_name")5driver.find_element(:link_text, "link_text").click6driver.find_element(:tag_name, "iframe").click7driver.switch_to.frame(0)8driver.find_element(:link_text, "link_text").click9driver.find_element(:tag_name, "iframe").click10driver.switch_to.frame(driver.find_element(:name, "frame_name"))11driver.find_element(:link_text, "link_text").click12driver.find_element(:tag_name, "iframe").click13driver.switch_to.frame(driver.find_element(:xpath, "//*[@id='frame_name']"))14driver.find_element(:link_text, "link_text").click

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1driver.switch_to.frame("frame_id")2driver.find_element(:id, "frame_id").click3frame = driver.find_element(:id, "frame_id")4driver.switch_to.frame(frame)5driver.find_element(:id, "frame_id").click6driver.switch_to.frame(0)7driver.find_element(:id, "frame_id").click8driver.switch_to.frame("frame_name")9driver.find_element(:id, "frame_id").click10driver.switch_to.frame("frame_name")11driver.find_element(:id, "frame_id").click12frame = driver.find_element(:name, "frame_name")13driver.switch_to.frame(frame)14driver.find_element(:id, "frame_id").click

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1driver.switch_to.frame("frame_name")2driver.switch_to.frame(0)3frame = driver.find_element(:xpath, "//*[@id='frame_name']")4driver.switch_to.frame(frame)

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1driver.switch_to.frame(0)2driver.find_element(:name, 'q').send_keys "Hello World"3driver.switch_to.frame("gsft_main")4driver.find_element(:name, 'q').send_keys "Hello World"5driver.switch_to.frame("gsft_main")6driver.find_element(:name, 'q').send_keys "Hello World"7element = driver.find_element(:name, 'q')8driver.switch_to.frame(element)9driver.find_element(:name, 'q').send_keys "Hello World"10driver.switch_to.frame("gsft_main")11driver.find_element(:name, 'q').send_keys "Hello World"12driver.find_element(:name, 'q').send_keys "Hello World"

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, "q").send_keys "Hello World"2driver.find_element(:name, "q").send_keys "Hello World"3frame = driver.find_element(:xpath, "//iframe[@id='iframeResult']")4driver.find_element(:name, "q").send_keys "Hello World"5driver.find_element(:name, "q").send_keys "Hello World"6driver.find_element(:name, "q").send_keys "Hello World"7driver.find_element(:name, "q").send_keys "Hello World"8driver.find_element(:name, "q").send_keys "Hello World"9driver.find_element(:link_text, "Gmail").click

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1search_box = browser.find_element(:name, 'q')2wait = Selenium::WebDriver::Wait.new(:timeout => 10)3wait.until { browser.title.downcase.start_with? "selenium webdriver" }4search_box = browser.find_element(:name, 'q')5wait = Selenium::WebDriver::Wait.new(:timeout => 10)6wait.until { browser.title.downcase.start_with? "selenium webdriver" }7search_box = browser.find_element(:name, 'q')8wait = Selenium::WebDriver::Wait.new(:timeout => 10)9wait.until { browser.title.downcase.start_with? "selenium webdriver" }10search_box = browser.find_element(:name, 'q')11wait = Selenium::WebDriver::Wait.new(:timeout => 10)12wait.until { browser.title.downcase.start_with? "selenium webdriver" }13driver.switch_to.frame(0)14driver.find_element(:name, 'q').send_keys "Hello World"15driver.switch_to.frame("gsft_main")16driver.find_element(:name, 'q').send_keys "Hello World"17driver.switch_to.frame("gsft_main")18driver.find_element(:name, 'q').send_keys "Hello World"19element = driver.find_element(:name, 'q')20driver.switch_to.frame(element)21driver.find_element(:name, 'q').send_keys "Hello World"22driver.switch_to.frame("gsft_main")23driver.find_element(:name, 'q').send_keys "Hello World"24driver.find_element(:name, 'q').send_keys "Hello World"

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, "q").send_keys "Hello World"2driver.find_element(:name, "q").send_keys "Hello World"3frame = driver.find_element(:xpath, "//iframe[@id='iframeResult']")4driver.find_element(:name, "q").send_keys "Hello World"5driver.find_element(:name, "q").send_keys "Hello World"6driver.find_element(:name, "q").send_keys "Hello World"7driver.find_element(:name, "q").send_keys "Hello World"8driver.find_element(:name, "q").send_keys "Hello World"9driver.find_element(:link_text, "Gmail").click

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1driver.switch_to.frame(0)2driver.find_element(:name, 'q').send_keys "Hello World"3driver.switch_to.frame("gsft_main")4driver.find_element(:name, 'q').send_keys "Hello World"5driver.switch_to.frame("gsft_main")6driver.find_element(:name, 'q').send_keys "Hello World"7element = driver.find_element(:name, 'q')8driver.switch_to.frame(element)9driver.find_element(:name, 'q').send_keys "Hello World"10driver.switch_to.frame("gsft_main")11driver.find_element(:name, 'q').send_keys "Hello World"12driver.find_element(:name, 'q').send_keys "Hello World"

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, "q").send_keys "Hello World"2driver.find_element(:name, "q").send_keys "Hello World"3frame = driver.find_element(:xpath, "//iframe[@id='iframeResult']")4driver.find_element(:name, "q").send_keys "Hello World"5driver.find_element(:name, "q").send_keys "Hello World"6driver.find_element(:name, "q").send_keys "Hello World"7driver.find_element(:name, "q").send_keys "Hello World"8driver.find_element(:name, "q").send_keys "Hello World"9driver.find_element(:link_text, "Gmail").click

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1search_box = browser.find_element(:name, 'q')2wait = Selenium::WebDriver::Wait.new(:timeout => 12)3wait.until { browser.title.downcase.start_with? "selenium webdriver" }4search_box = browser.find_element(:name, 'q')5wait = Selenium::WebDriver::Wait.new(:timeout => 10)6wait.until { browser.title.downcase.start_with? "selenium webdriver" }7search_box = browser.find_element(:name, 'q')8wait = Selenium::WebDriver::Wait.new(:timeout => 10)9wait.until { browser.title.downcase.start_with? "selenium webdriver" }10search_box = browser.find_element(:name, 'q')11wait = Selenium::WebDriver::Wait.new(:timeout => 10)12wait.until { browser.title.downcase.start_with? "selenium webdriver" }

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1driver.switch_to.frame("frame_name")2driver.find_element(:link_text, "link_text").click3driver.find_element(:tag_name, "iframe").click4driver.switch_to.frame("frame_name")5driver.find_element(:link_text, "link_text").click6driver.find_element(:tag_name, "iframe").click7driver.switch_to.frame(0)8driver.find_element(:link_text, "link_text").click9driver.find_element(:tag_name, "iframe").click10driver.switch_to.frame(driver.find_element(:name, "frame_name"))11driver.find_element(:link_text, "link_text").click12driver.find_element(:tag_name, "iframe").click13driver.switch_to.frame(driver.find_element(:xpath, "//*[@id='frame_name']"))14driver.find_element(:link_text, "link_text").click

Full Screen

Full Screen

frame

Using AI Code Generation

copy

Full Screen

1search_box = browser.find_element(:name, 'q')2wait = Selenium::WebDriver::Wait.new(:timeout => 10)3wait.until { browser.title.downcase.start_with? "selenium webdriver" }4search_box = browser.find_element(:name, 'q')5wait = Selenium::WebDriver::Wait.new(:timeout => 10)6wait.until { browser.title.downcase.start_with? "selenium webdriver" }7search_box = browser.find_element(:name, 'q')8wait = Selenium::WebDriver::Wait.new(:timeout => 10)9wait.until { browser.title.downcase.start_with? "selenium webdriver" }10search_box = browser.find_element(:name, 'q')11wait = Selenium::WebDriver::Wait.new(:timeout => 10)12wait.until { browser.title.downcase.start_with? "selenium webdriver" }

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful