daily pastebin goal
52%
SHARE
TWEET

Actions

a guest Jun 19th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from selenium.webdriver import ActionChains
  2. from selenium.webdriver.support.wait import WebDriverWait
  3.  
  4. from rita.rita.ui_autotests.Pages.invoice_pages import *
  5. from rita.rita.ui_autotests.Pages.common_functionality_pages import *
  6.  
  7.  
  8. invoice = Invoice()
  9. invoice_mod = ModifyInvoice()
  10. invoice_list = InvoiceList()
  11. set_smth = FuctionalButtons()
  12.  
  13. class Invoice_Actions(object):
  14.  
  15.     def user_modifies_company_field_in_invoice(self, driver, test_invoice_id, new_company_name):
  16.  
  17.         previous_company_name = invoice_mod.get_company_name(invoice_id=test_invoice_id)
  18.  
  19.         invoice_mod.modify_invoice(invoice_id=test_invoice_id)
  20.         invoice_mod.change_company(company_name=new_company_name)
  21.         invoice_mod.save_changes()
  22.  
  23.         driver.refresh()
  24.  
  25.         current_company_name = invoice_mod.get_company_name(invoice_id=test_invoice_id)
  26.         return (current_company_name, previous_company_name)
  27.  
  28.  
  29.     def user_cancels_invoice_modify(self, driver, test_invoice_id):
  30.  
  31.         previous_state = invoice_mod.get_state(invoice_id=test_invoice_id)
  32.         invoice.highlight_invoice(invoice_id=test_invoice_id)
  33.  
  34.         invoice_mod.modify_invoice(invoice_id=test_invoice_id)
  35.         new_state = "paid"
  36.         invoice_mod.change_state(state=new_state)
  37.         time.sleep(2)
  38.         invoice_mod.close_modify()
  39.  
  40.         driver.refresh()
  41.  
  42.         current_state = invoice_mod.get_state(invoice_id=test_invoice_id)
  43.  
  44.         return previous_state, current_state, new_state
  45.  
  46.  
  47.     def user_modifies_creator_field_in_invoice(self, driver, test_invoice_id, test_new_creator):
  48.  
  49.         previous_creator = invoice_mod.get_creator(invoice_id=test_invoice_id)
  50.  
  51.         invoice_mod.modify_invoice(invoice_id=test_invoice_id)
  52.         invoice_mod.change_creator(new_creator=test_new_creator)
  53.         time.sleep(2)
  54.         invoice_mod.save_changes()
  55.  
  56.         driver.refresh()
  57.  
  58.         current_creator = invoice_mod.get_creator(invoice_id=test_invoice_id)
  59.  
  60.         return previous_creator, current_creator
  61.  
  62.  
  63.     def user_modifies_state_field_in_invoice(self, driver, test_invoice_id, new_state):
  64.  
  65.         previous_state = invoice_mod.get_state(invoice_id=test_invoice_id)
  66.         print(previous_state)
  67.         invoice.highlight_invoice(invoice_id=test_invoice_id)
  68.  
  69.         invoice_mod.modify_invoice(invoice_id=test_invoice_id)
  70.         invoice_mod.change_state(state=new_state)
  71.         time.sleep(2)
  72.  
  73.         invoice_mod.save_changes()
  74.  
  75.         driver.refresh()
  76.  
  77.         current_state = invoice_mod.get_state(invoice_id=test_invoice_id)
  78.         print(current_state)
  79.  
  80.         return previous_state, current_state
  81.  
  82.  
  83.     def user_modifies_payee_field_in_invoice(self, driver, test_invoice_id, new_payee_value):
  84.  
  85.         invoice_mod.modify_invoice(invoice_id=test_invoice_id)
  86.         previous_payee = invoice_mod.get_payee()
  87.         print(previous_payee)
  88.         time.sleep(2)
  89.         invoice_mod.change_payee(new_payee_value)
  90.         invoice_mod.save_changes()
  91.  
  92.         driver.refresh()
  93.  
  94.         invoice_mod.modify_invoice(invoice_id=test_invoice_id)
  95.         current_payee = invoice_mod.get_payee()
  96.         print(current_payee)
  97.         time.sleep(2)
  98.         invoice_mod.change_payee(previous_payee)
  99.         invoice_mod.save_changes()
  100.  
  101.         driver.refresh()
  102.  
  103.         return previous_payee, current_payee
  104.  
  105.     def extra_spaces_are_skipped_when_modify_invoice(self, driver, test_invoice_id):
  106.  
  107.         invoice_mod.modify_invoice(invoice_id=test_invoice_id)
  108.         new_payee_value = "                                                    Amélie Dubois                         " \
  109.                           "" \
  110.  
  111.         time.sleep(2)
  112.         invoice_mod.change_payee(new_payee=new_payee_value)
  113.         time.sleep(2)
  114.         invoice_mod.save_changes()
  115.         time.sleep(2)
  116.  
  117.         invoice_mod.modify_invoice(invoice_id=test_invoice_id)
  118.         current_payee = invoice_mod.get_payee()
  119.  
  120.         new_payee_value_without_spaces = "Amélie Dubois"
  121.  
  122.         time.sleep(2)
  123.         invoice_mod.change_payee(new_payee="to be changed")
  124.         invoice_mod.save_changes()
  125.  
  126.         driver.refresh()
  127.  
  128.         invoice_mod.modify_invoice(invoice_id=test_invoice_id)
  129.         print (invoice_mod.get_payee())
  130.  
  131.         return current_payee, new_payee_value_without_spaces
  132.  
  133.     def user_opens_invoice_details(self, driver, test_invoice_id):
  134.  
  135.         invoice.open_invoice(invoice_id=test_invoice_id)
  136.  
  137.         driver.switch_to_window(driver.window_handles[1])
  138.  
  139.         return invoice.get_invoice_id_from_open_page()
  140.  
  141.     def user_downloads_pdf(self, driver, test_invoice_id):
  142.  
  143.         invoice_list.click_on_pdf_download(invoice_id=test_invoice_id)
  144.         time.sleep(2)
  145.  
  146.         return invoice_list.get_invoice_number(invoice_id=test_invoice_id)
  147.  
  148.     def user_accepts_invoice(self, driver, new_invoice_id):
  149.  
  150.         invoice_list.click_accept_invoice(new_invoice_id)
  151.         wait = WebDriverWait(driver, 10)
  152.         wait.until(EC.presence_of_element_located(by_xpath(invoice_list._get_confirm_modal_path())))
  153.  
  154.         invoice_list.confirm_accept_invoice()
  155.         time.sleep(10)
  156.  
  157.         return invoice_mod.get_state(new_invoice_id)
  158.  
  159.     def user_cancels_invoice_acceptance(self, driver, new_invoice_id):
  160.  
  161.         invoice_list.click_accept_invoice(new_invoice_id)
  162.         wait = WebDriverWait(driver, 5)
  163.         wait.until(EC.presence_of_element_located(by_xpath(invoice_list._get_confirm_modal_path())))
  164.  
  165.         invoice_list.cancel_accept_or_clone_invoice()
  166.  
  167.         return invoice_mod.get_state(new_invoice_id)
  168.  
  169.     def user_clones_and_void_invoice(self, driver, test_invoice_id):
  170.  
  171.         invoice_list.click_clone_invoice( invoice_id=test_invoice_id )
  172.         btn = invoice_list.confrim_clone_or_void_invoice()
  173.         void = invoice_list.void_invoice_when_clonning()
  174.         ActionChains( driver ).move_to_element( void ).click().perform()
  175.         ActionChains( driver ).move_to_element( btn ).click().perform()
  176.  
  177.         return self
  178.  
  179.  
  180.     def user_cancels_clone_and_void_invoice(self, driver, test_invoice_id):
  181.  
  182.         invoice_list.click_clone_invoice( invoice_id=test_invoice_id )
  183.         void = invoice_list.void_invoice_when_clonning()
  184.         ActionChains( driver ).move_to_element( void ).click().perform()
  185.         invoice_list.cancel_accept_or_clone_invoice()
  186.         return self
  187.  
  188.     def user_voides_invoice(self, driver, test_invoice_id):
  189.  
  190.         invoice_list.check_state(status="paid", invoice_id=test_invoice_id)
  191.         invoice_list.click_void_invoice(test_invoice_id)
  192.         time.sleep(2)
  193.         btn = invoice_list.confrim_clone_or_void_invoice()
  194.         ActionChains(driver).move_to_element(btn).click().perform()
  195.         time.sleep(2)
  196.         return self
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top