Module: XlsxParser

Defined in:
lib/parser/xlsx_parser.rb

Overview

Created on 02 Aug 2018 @author: Andy Perrett

Versions: 1.0 - Baseline

xlsx_parser.rb - xlsx parser functions

Class Method Summary collapse

Class Method Details

.parse_test_step_data(_test_file_type) ⇒ Object

parseTestStepData



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/parser/xlsx_parser.rb', line 25

def self.parse_test_step_data(_test_file_type)
  worksheet = $xlsxDoc[0]
  worksheet[4..$numberOfTestSteps + 4].map do |row|
    test = {
      testStep: row[0].value,
      testdesc: row[1].value,
      testFunction: row[2].value,
      testvalue: row[3].value,
      locate: row[4].value,
      testvalue2: row[5].value,
      locate2: row[6].value,
      screenShotData: row[7].value,
      skipTestCase: row[8].value
    }

    # convert test step, screenshot and skip test case functions to lowercase.
    test[:testFunction].downcase!

    # get screenshot request, check for a null value and default to 'N'

    test[:screenShotData] = if test[:screenShotData] == 'Y'
                              true
                            elsif test[:screenShotData] == 'N'
                              false
                            else
                              false
                            end

    test[:skipTestCase] = if test[:skipTestCase] == 'Y'
                            true
                          elsif test[:skipTestCase] == 'N'
                            false
                          else
                            false
                          end

    # if there is an element locator then use it, otherwise use an ID
    test[:locate] = 'id' if test[:locate].to_s == ''

    test[:locate2] = 'id' if test[:locate2].to_s == ''

    test
  # if an error reading the test step data then re-raise the exception
  rescue StandardError => error
    raise error
  end
end

.parse_xlxs_test_header_dataObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/parser/xlsx_parser.rb', line 11

def self.parse_xlxs_test_header_data
  # get the number of test steps in the file
  $numberOfTestSteps = $xlsxDoc[0].sheet_data.size - 4
  worksheet = $xlsxDoc[0]
  # get the remaining test data
  $testId = worksheet.sheet_data[1][0].value
  $projectId    = worksheet.sheet_data[1][1].value
  $testDes      = worksheet.sheet_data[1][2].value
  MyLog.log.info "Number of test steps: #{$numberOfTestSteps}"
  MyLog.log.info "Test Description: #{$testDes}"
  MyLog.log.info "TestID: #{$testId} \n"
end