Module | Oats |
In: |
lib/oats.rb
lib/oats_data.rb |
Return oats.yml entry for given string or the whole hash
Oats.data['selenium']['browser'] == 'firefox'
Raises OatsAssertError unless two parameters are ’==’ If given pre_message preceeds the standard message showing expected and actuals. Example: Oats.assert_equal(old_count, new_count, "After deletion, creative counts did not decrease.")
Returns a browser (selenium driver), logging into RL site or opening URL. The browser is retrieved and reused in the subsequent rtest.*rb executions, but it is automatically closed at the end of each Oats test. If exists, the browser is also accessable via the global $selenium.
Parameters:
url_or_site: | A URL, or site:
[Campaign, Admin, Vendor, VendorApprover, Solutions, SolutionsApprover ] Required parameter for the first invocation, can be omitted in subsequent invocations to get the current browser. Re-issueing it w/o logging out of the same site will reopen the landing page. A different site will cause logout of the old site and login to the new site. User will be created if it does not already exists. |
new_browser: | If true, will create a new browser while keeping the old one. |
Methods in addition to the selenium driver methods are:
login(site): | Same as Oats.browser(url_or_site), for a site. Returns nil if site is not recognized. |
logout: | Logs out of the last logged in sites if any and returns browser. Logout may not succeed if logout button is unavailable. |
Examples:
browser = Oats.browser('Campaign') browser.click("link=View Advertisers") browser.login('Admin') browser.logout
Returns hash object containing info about persistent oats internal variables for the complete oats execution. Contents of Oats.context are also persisted into the results.dump in the results directory.
Examples:
Oats.context['stop_oats'] == true # Request stopping oats after current test
Hash object providing access to the oats.yml state entries at the time of test execution. Note that Oats.data contents are isolated from modification across tests.
map_string:: Period seperated YAML path into the current Oats.data If not specified, returns the full hash.
Examples:
Oats.data 'selenium.browser' == 'firefox Oats.data['selenium']['browser'] == 'firefox'
Removes the variabilities from files in ‘Oats.test.result’ by applying prescribed filter to each line of file and replaces it. The return value is the filtered contents of the file. The filtered contents are also placed in test.out to be compared as expected results. Errors will raise OatsFilterError.
Parameters:
in_file: | Name or path of file that is to be filtered and moved to Oats.test.out. It can also be String Array or String containing the actual contents. If the file contains a space, it is assumed to be contents. Missing input or file raises OatsFilterError. |
out_file: | File name to use for the output file. This is an optional parameter which can be skipped. If skipped, basename of the infile is used. |
pattern: | A regexp pattern to pass on to a gsub or grep method. Grep is used if replacement parameter is unspecified, in other words file_contents.grep(/pattern_string/) |
replacement: | Fixed string to replace the pattern by calling file_contents.gsub(pattern,replacement) |
Examples:
Oats.filter('input.txt') # Moves input.txt to test.out for auto-verification. Oats.filter('input.txt','output.txt,/this/) # Considers only lines containing 'this' Oats.filter('input.txt',/this.*that/,'thisAndThat') # Replaces indicated content Oats.filter('input.txt') { |line| line unless line == 'this\n' } # Omits 'this\n' line
Runs the input_suite_path from a particular Oats.test. Assumes Oats.data is initialized for Oats.test
Parameters:
input_suite_path: | path to the IDE suite HTML |
hash: | list from => to values to use for regeneration of the included test |
cases.
Examples:
Oats.ide.run('../campaign/rtest.html', 'this_token" => 'that_value')
Examples
Oats.mysql('input.sql') => produces input.txt and returns its contents Oats.mysql('input.sql', 'output.txt) => produces output.txt and returns its contents mysql_results = Oats.mysql "SELECT bu_lastname, FROM BusinessUser where bu_email='levent.atasoy@oats.org;XYZ'" result = Oats.mysql(my_sql_statement) result.is_empty? # true if SQL returns nothing result.last # string value for the last row of a single select statement result[1][2] # second column for the first return result row
Creates a file handle to output into the out directory with given name Returns the comparison with any previous ok file if exists.
Parameters:
file_name: Appends '_<count>' to the this name if the file already exists. output: String to output, must supply only if a block is not given. is_assert: If set to true to assert failure when ok file exists and differs. Examples:
Oats.out_file(‘my_file.txt’, "Check this string" } Oats.out_file(‘my_file.txt’) { |f| f.puts "Check this string" }
Copies a file to the server via ssh using PuTTy/plink Assumes pageant with keys for the username is up and running. Returns the result of the standard output and standard error, which is typically empty.
Parameters:
content_file: | Path of the content file, or the content string if file |
does not exist.
target_file_path: | Path of the file on the server |
host/session: Same parameter as in Oats.rssh
username: | Same parameter as in Oats.rssh |
Examples
Oats.rput 'xxx xxxxxxx', '/tmp/myfile.txt' , 'qapp001.dyn.wh.oats.org' Oats.rput 'c:/qa/oats-user.yml', '/tmp/myfile.txt' , 'qapp001.dyn.wh.oats.org'
Executes a script on an server via ssh using PuTTy/plink Assumes pageant with keys for the username is up and running. Returns the result of the standard output and standard error.
Parameters:
cmd_file: | Path of the executable relative to dir |
dir: | Directory to cd prior to executing cmd_file. Home of user if omitted. |
host/session: Name for putty on which to execute cmd_file. Defaults via Oats.data
username: | Putty connection data Login username. Defaults via Oats.data. |
If username is 'root', executes the cmd_file as sudo root with Oats.data[ssh.root_sudo_username]. root_sudo_username must be able to - access host via Plink/Pageant - sudo -s on the host - cd to dir without being root.
Examples
out = Oats.rssh('/rl/www/vhosts/baselevel/automation/run_qr_transfer.pl') Oats.rssh('./run_qr_transfer.pl', /rl/www/vhosts/baselevel/automation') Oats.rssh('cat .config.yaml','/var/www/vhosts/baselevel') Oats.rssh('ls httpd', '/var/log', nil, 'root')
Returns an intermediary object that invokes selenium with fields optionally mapped based on YAML entries. Subsequent invocations (with optional method override)
object.invoke(field,value, method)
will invoke ’$selenium.method field, value‘
Parameters:
mapping: A string in which YAML nodes are separated by '.' and pointing to the final hash node in Oats.data that containing the field mappings. method: Default method invoked by selenium. Default is ':type' Methods for 'type' and 'select' can also be called directly
Examples:
sel = Oats.selenium "SolutionsVendor.create_vendor" sel.invoke "address1", "21700 Oxnard Street" Will replace address1 with contents of SolutionsVendor:create_vendor:address1 in Oats.data sel.type "address1", "21700 Oxnard Street" sel.select "state", "label=CALIFORNIA"
Raise OatsTestExit and SKIP current test if there was a previous test and if previous test dif not pass or or_if_true is true
Samples the given block each second until it returns true or times out. Raises OatsTestError if times out or returns true.
Parameters (also allowed as Hash):
message: Exception message to issue upon timeout. seconds: For timeout, defaults from Oats.data selenium.command_timeout is_return: Returns false if times out instead of raising OatsTestError.
Example:
Oats.wait_until("SolutionsVendor.create_vendor", 100) do count = count + 1; count == 10 end