Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. def get_object_xpath(test_case, object_type):
  2. """Find the xpath for object type in the catalog browser"""
  3. driver = test_case.driver
  4. database_display_name = test_case.database_display_name
  5. connection_uid = test_case.connection_uid
  6. expand_database_and_catalog_node(driver, database_display_name, connection_uid, object_type) # great
  7. object_xpath = get_objects_xpath(driver, database_display_name, connection_uid, object_type)
  8.  
  9.  
  10. return object_xpath
  11.  
  12. def catalog_object_option_map(option):
  13. """Defines the navigation rules for catalog object dropdowns"""
  14. open_definition = "//li[contains(@id,'catalogbrowserlist.openDefinition')]"
  15. open_data = "//li[contains(@id,'catalogbrowserlist.openContent')]"
  16. debug = "//li[contains(@id,'catalogbrowserlist.openForDebugging')]"
  17. delete = "//li[contains(@id,'catalogbrowserlist.delete')]"
  18. export = "//li[contains(@id,'catalogbrowserlist.openExport')]"
  19. call_proc = "//li[contains(@id,'catalogbrowserlist.invokeProcedure')]"
  20. call_proc_ui = "//li[contains(@id, 'catalogbrowserlist.invokeProcedureWithUI')]"
  21. create_shortcut = "//li[contains(@id,'catalogbrowserlist.copyShortcut')]"
  22. whereused = "//li[contains(@id,'objectdependencebrowser.open')]"
  23. opensql = "//li[contains(@id,'catalogbrowserlist.openSqlConsole')]"
  24. openmdx = "//li[contains(@id,'catalogbrowserlist.openMdxConsole')]"
  25. open_object_search = "//li[contains(@id,'searchbrowser.catalog.open')]"
  26. open_mdx_search = "//li[contains(@id,'mdxbrowser.catalog.open')]"
  27.  
  28. object_map = {'open': open_definition, 'open_data': open_data,
  29. 'debug': debug, 'delete': delete, 'export': export,
  30. 'generate_call': call_proc, 'generate_call_ui': call_proc_ui,
  31. 'shortcut': create_shortcut, 'whereused': whereused,
  32. 'opensql': opensql, 'openmdx': openmdx, 'open_object_search': open_object_search,
  33. 'open_mdx_search': open_mdx_search}
  34. try:
  35. return object_map[option]
  36. except KeyError:
  37. print ('support for {} not added in yet'.format(option))
  38.  
  39.  
  40. def open_catalog_object_option(test_case, object_name, object_type, option, hdi=False):
  41. driver = test_case.driver
  42.  
  43. catalog_xpath = get_object_xpath(test_case, object_type)
  44. click_button_by_xpath(driver, catalog_xpath)
  45.  
  46. snooze(pauseTime * 5)
  47. type_in_by_xpath(driver, left_sidebar_search_xpath, object_name)
  48. snooze(pauseTime * 5)
  49. catalog_list_object_xpath = get_catalog_object_xpath(driver, catalog_list_xpath, object_name)
  50.  
  51. if catalog_list_object_xpath:
  52. snooze(pauseTime)
  53. right_click_by_xpath(driver, catalog_list_object_xpath)
  54. snooze(pauseTime * 12)
  55. option_number = catalog_object_option_map(option)
  56. # go_down(driver, option_number)
  57. click_button_by_xpath(driver, option_number)
  58. snooze(pauseTime * 5)
  59. else:
  60. raise Exception('Couldn\'t find object in bottom left catalog browser')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement