Class: CUKES::RubyGems
- Inherits:
-
Object
- Object
- CUKES::RubyGems
- Includes:
- FileLibrary, ObjectRepository::OR_RubyGems, PageUtils, PageObject
- Defined in:
- lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb
Instance Method Summary collapse
-
#compare_heading(gem_name) ⇒ Object
Description : compares the gem header name Author : Chandra sekaran Argument : gem_name : name of the gem.
-
#fetch_desired_gem ⇒ Object
Description : searches for the specific gem and selects it Author : Chandra sekaran.
-
#fetch_gem_details(gem) ⇒ Object
Description : fetches the gem details Author : Chandra sekaran Argument : gem : name of the gem.
-
#fetch_gem_development_dependencies ⇒ Object
Description : fetches the gem development dependencies Author : Chandra sekaran.
-
#fetch_gem_ruby_dependencies ⇒ Object
Description : fetches the gem ruby dependencies Author : Chandra sekaran.
-
#fetch_gem_runtime_dependencies ⇒ Object
Description : fetches the gem runtime dependencies Author : Chandra sekaran.
-
#fetch_gem_versions ⇒ Object
Description : fetches the gem version Author : Chandra sekaran.
-
#fetch_list_items(parent_element) ⇒ Object
Description : fetches the text under list of elements Author : Chandra sekaran Argument : parent_element : parent element object.
-
#initialize_page ⇒ Object
Description : invoked automatically when the page class object is created Author : Chandra sekaran.
-
#search_for_gem(gem_name = "", str_data_node = "gems") ⇒ Object
Description : searches for the given input gem name Author : Chandra sekaran Arguments : gem_name : name of the gem str_data_node : test data root node name.
-
#sign_in ⇒ Object
Description : sign into the application Author : Chandra sekaran.
-
#sign_out ⇒ Object
Description : sign out from the application Author : Chandra sekaran.
-
#split_gem_and_version(gem) ⇒ Object
Description : splits gem name and its version from given input string Author : Chandra sekaran Argument : gem : gem name string with version Return Arguments : gem_name : gem name gem_version : gem version.
Methods included from FileLibrary
#close_file, #create_directory, #create_html_report, delete_object, #execute_command, #format_file_path, #get_feature_module_name, #get_files_absolute_path, #is_file_exists, #open_excel_file, #open_yml_file, #rename_file_type, #set_datafile_path, #set_scenario_based_datafile
Methods included from PageUtils
#click_on, #compare_string, #get_execution_delay_time, #get_steps, #is_text_present, #refresh_page, #switch_to_application_window, #switch_to_next_window, #wait_ajax_for_loading, #wait_for_object, #wait_for_page_load
Instance Method Details
#compare_heading(gem_name) ⇒ Object
Description : compares the gem header name Author : Chandra sekaran Argument :
gem_name : name of the gem
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 82 def compare_heading(gem_name) wait_for_object(h1_title_element) expected_heading = "search for #{gem_name}" actual_heading = h1_title_element.text raise "The expected heading is #{expected_heading} but actual heading is #{actual_heading}" if actual_heading != expected_heading wait_for_object(div_search_result_element, "Could not find gem result list") raise "No gems found for the given gem" if div_search_result_element.text.include?("No gems found") rescue Exception => ex $log.error("Failure while comparing Gem header for gem '#{gem_name}' : #{ex}") exit end |
#fetch_desired_gem ⇒ Object
Description : searches for the specific gem and selects it Author : Chandra sekaran
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 97 def fetch_desired_gem gem_object = "" gem_name = "" max = 0 div_search_result_element.link_elements(:xpath => "./a").each do |parent| current = parent.paragraph_element(:xpath => "./p").text current = current.gsub!(',','').to_i if current.include?(',') if max < current.to_i max = current.to_i gem_object = parent.strong_element(:xpath => "./div/h2") end end gem_name = gem_object.text gem_object.click gem_name rescue Exception => ex $log.error("Failure while getting desired gem : #{ex}") exit end |
#fetch_gem_details(gem) ⇒ Object
Description : fetches the gem details Author : Chandra sekaran Argument :
gem : name of the gem
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 122 def fetch_gem_details(gem) wait_for_object(h1_title_element) gem_name, gem_version = split_gem_and_version(gem) gem_heading = gem_name + " " + gem_version raise "The expected value is '#{gem_heading}' but the actual value is '#{h1_title_element.text}'" if h1_title_element.text != gem_heading $log.info "Gem Description" $log.info "\tGem Name : #{h1_title_element.text}" $log.info "\tGem install : #{textfield_gem_install_elements.last.value}" $log.info "\tGemfile : #{textfield_gem_install_elements.first.value}" fetch_gem_versions fetch_gem_runtime_dependencies fetch_gem_ruby_dependencies fetch_gem_development_dependencies rescue Exception => ex $log.error("Failure while fetching Gem details for gem '#{gem_name}' : #{ex}") exit end |
#fetch_gem_development_dependencies ⇒ Object
Description : fetches the gem development dependencies Author : Chandra sekaran
170 171 172 173 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 170 def fetch_gem_development_dependencies $log.info "Ruby Dependency" fetch_list_items(div_gem_development_dependencies_element) end |
#fetch_gem_ruby_dependencies ⇒ Object
Description : fetches the gem ruby dependencies Author : Chandra sekaran
162 163 164 165 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 162 def fetch_gem_ruby_dependencies $log.info "Ruby Dependency" fetch_list_items(div_gem_ruby_dependencies_element) end |
#fetch_gem_runtime_dependencies ⇒ Object
Description : fetches the gem runtime dependencies Author : Chandra sekaran
154 155 156 157 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 154 def fetch_gem_runtime_dependencies $log.info "Runtime Dependencies" fetch_list_items(div_gem_runtime_dependencies_element) end |
#fetch_gem_versions ⇒ Object
Description : fetches the gem version Author : Chandra sekaran
146 147 148 149 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 146 def fetch_gem_versions $log.info "Versions" fetch_list_items(div_gem_version_element) end |
#fetch_list_items(parent_element) ⇒ Object
Description : fetches the text under list of elements Author : Chandra sekaran Argument :
parent_element : parent element object
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 180 def fetch_list_items(parent_element) if parent_element.exists? && parent_element.visible? list_elements = "" if parent_element.div_element(:xpath => "./div[@class='t-list__items']").exists? list_elements = parent_element.link_elements(:xpath => "./div[@class='t-list__items']/a") elsif parent_element.ordered_list_element(:xpath => "./ol").exists? list_elements = parent_element.list_item_elements(:xpath => "./ol/li") end list_elements.each do |list| $log.info "\t #{list.text}" end else $log.info "\t No data found" end rescue Exception => ex $log.error("Failure while fetching gem list items : #{ex}") exit end |
#initialize_page ⇒ Object
Description : invoked automatically when the page class object is created Author : Chandra sekaran
19 20 21 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 19 def initialize_page wait_for_page_load end |
#search_for_gem(gem_name = "", str_data_node = "gems") ⇒ Object
Description : searches for the given input gem name Author : Chandra sekaran Arguments :
gem_name : name of the gem
str_data_node : test data root node name
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 59 def search_for_gem(gem_name = "", str_data_node = "gems") if gem_name == "" # the set_scenario_based_datafile method sets the test data content from the given input file name # present in library/app_specific/datafile_names.rb # the yml file can be : # * a local data file - inside the current feature name directory # * a global data file - inside desktop directory hash_gem_name = set_scenario_based_datafile(GEM_NAME) gem_name = hash_gem_name[str_data_node]["gem_name"] end wait_for_object(input_search_element, "Could not find search textbox") self.input_search = gem_name input_search_element.send_keys(:enter) rescue Exception => ex $log.error("Failure while searching for gem '#{gem_name}' : #{ex}") exit end |
#sign_in ⇒ Object
Description : sign into the application Author : Chandra sekaran
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 26 def sign_in click_on(link_signin_element) wait_for_object(textfield_email_element, "Could not find textfield Email") self.textfield_email = USER_NAME # "[email protected]" self.textfield_password = PASSWORD # "chan123@1" click_on() wait_for_page_load #raise "Error in sign in" if !is_text_present(self, "CHAN90", 120) $log.success("Sign in successful") rescue Exception => ex $log.error("Failure while signing in : #{ex}") exit end |
#sign_out ⇒ Object
Description : sign out from the application Author : Chandra sekaran
43 44 45 46 47 48 49 50 51 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 43 def sign_out click_on() click_on(link_signout_element) #raise "Error in sign out" if !is_text_present(self, "Sign in", 120) $log.success("Sign out successful") rescue Exception => ex $log.error("Failure while signing out : #{ex}") exit end |
#split_gem_and_version(gem) ⇒ Object
Description : splits gem name and its version from given input string Author : Chandra sekaran Argument :
gem : gem name string with version
Return Arguments :
gem_name : gem name
gem_version : gem version
207 208 209 210 211 |
# File 'lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb', line 207 def split_gem_and_version(gem) gem_name = gem.split(" ").first gem_version = gem.split(" ").last return gem_name, gem_version end |