Class: Language

Inherits:
Object
  • Object
show all
Defined in:
lib/skeleton/languages.rb

Constant Summary collapse

JAVA =
'java'.freeze
RUBY =
'rb'.freeze
PYTHON =
'py'.freeze
JAVASCRIPT =
'js'.freeze
SWIFT =
'swift'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject



69
70
71
# File 'lib/skeleton/languages.rb', line 69

def self.all
  %w[ruby java python javascript swift]
end

.domain(format) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/skeleton/languages.rb', line 52

def self.domain(format)
  case format
  when 'ruby', 'rb'
    RUBY
  when 'java'
    JAVA
  when 'javascript', 'js'
    JAVASCRIPT
  when 'python', 'py'
    PYTHON
  when 'swift'
    SWIFT
  else
    "I haven't this language format"
  end
end

Instance Method Details

#java(camel_method_name:, locator_type:, locator_value:) ⇒ Object



8
9
10
11
12
13
# File 'lib/skeleton/languages.rb', line 8

def java(camel_method_name:, locator_type:, locator_value:)
  <<~JAVA
    By #{camel_method_name} = MobileBy.#{locator_type[:java]}("#{locator_value}");

  JAVA
end

#js(camel_method_name:, locator_type:, locator_value:) ⇒ Object



29
30
31
32
33
34
# File 'lib/skeleton/languages.rb', line 29

def js(camel_method_name:, locator_type:, locator_value:)
  <<~JS
    let #{camel_method_name} = await driver.elements("#{locator_type[:javascript]}", "#{locator_value}");

  JS
end

#python(snake_method_name:, locator_type:, locator_value:) ⇒ Object



22
23
24
25
26
27
# File 'lib/skeleton/languages.rb', line 22

def python(snake_method_name:, locator_type:, locator_value:)
  <<~PYTHON
    #{snake_method_name} = self.driver.#{locator_type[:python]}("#{locator_value})"

  PYTHON
end

#ruby(snake_method_name:, locator_type:, locator_value:) ⇒ Object



15
16
17
18
19
20
# File 'lib/skeleton/languages.rb', line 15

def ruby(snake_method_name:, locator_type:, locator_value:)
  <<~RUBY
    #{snake_method_name} = :#{locator_type[:ruby]}, "#{locator_value}"

  RUBY
end

#swift(camel_method_name:, element_type:, locator_value:, accessibility_id:) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/skeleton/languages.rb', line 36

def swift(camel_method_name:, element_type:, locator_value:, accessibility_id:)
  if accessibility_id
  <<~SWIFT
    let #{camel_method_name} = app.#{element_type}["#{locator_value}"]

  SWIFT
  else
    <<~SWIFT
    let #{camel_method_name} = app.#{element_type}.matching(
      NSPredicate(format: "#{locator_value}")
    ).element

    SWIFT
  end
end