legoTech_gem 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +135 -7
- data/legoTech.gemspec +1 -1
- data/lib/legoTech_gem.rb +0 -1
- data/lib/ui/actions/Action.rb +82 -9
- data/lib/ui/driver/Driver.rb +25 -4
- data/lib/ui/enums/FieldType.rb +10 -0
- data/lib/ui/enums/Identifier.rb +3 -3
- data/lib/ui/test-cases/TestCase.rb +63 -1
- data/lib/ui/test-suites/TestSuite.rb +20 -9
- data/lib/ui/validate/ValidateElement.rb +86 -0
- metadata +4 -3
- data/lib/ui/enums/Field.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3473c8222c2746357db699716897be3e93e2e2e09b281d38f23b77225d61a47f
|
4
|
+
data.tar.gz: 92154882a866343da76af76f0ed66954fcb69f6e9fbe341588d3db7df149e5b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da884052353e8b4c88dbe4c19a7c8eb773f3f21ad3d65e1519127969c7d28fc2a397a43c16fd8bfe6acb48a8ab7ddfc2254f3d1d9a68fd2fe6a5a70d9f8c8b21
|
7
|
+
data.tar.gz: e7f784b4c166047e170d8d1b476a5ececcc337a7d30594ffc48124d669cb1057cfa6e99848ce5988cff0aeb695323e3afac8dcfb97787537cacd354051edeae9
|
data/README.md
CHANGED
@@ -1,11 +1,78 @@
|
|
1
1
|
# Ruby-Selenium
|
2
|
-
A Ruby gem to help developers write test cases for the UI
|
3
2
|
|
4
|
-
|
5
|
-
Comments and tags must respect the naming from: https://rubydoc.info/gems/yard/file/docs/Tags.md
|
6
|
-
Ruby Types are defined here: https://www.geeksforgeeks.org/ruby-data-types/
|
3
|
+

|
7
4
|
|
8
|
-
|
5
|
+
A Ruby gem to help developers write test cases for a UI.
|
6
|
+
|
7
|
+
Create Action
|
8
|
+
```
|
9
|
+
def get_check_box_action(driver)
|
10
|
+
# Create your action
|
11
|
+
RadioButtonAction.new(driver)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_radio_button_action(driver)
|
15
|
+
# Create your action
|
16
|
+
CheckBoxAction.new(driver)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_input_action(driver)
|
20
|
+
# Create your action
|
21
|
+
InputAction.new(driver)
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_select_action(driver)
|
25
|
+
# Create your action
|
26
|
+
SelectAction.new(driver)
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_button_action(driver)
|
30
|
+
# Create your action
|
31
|
+
ButtonAction.new(driver)
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
Create Test Case
|
36
|
+
```
|
37
|
+
def get_test_case(driver)
|
38
|
+
LegoTechSelenium::TestCase::Builder.new("My first test case", driver)
|
39
|
+
.add_action(get_input_action(driver))
|
40
|
+
.add_action(get_select_action(driver))
|
41
|
+
.add_action(get_button_action(driver))
|
42
|
+
.add_action(get_check_box_action(driver))
|
43
|
+
.add_action(get_radio_button_action(driver))
|
44
|
+
.build
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
Create a Test Suite
|
49
|
+
```
|
50
|
+
def get_test_suite(driver)
|
51
|
+
LegoTechSelenium::TestSuite::Builder.new("My first test suite", driver)
|
52
|
+
.add_test_case(get_test_case(driver))
|
53
|
+
.build
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
**And Off you go!**
|
58
|
+
|
59
|
+
```
|
60
|
+
testSuite = get_test_suite(driver)
|
61
|
+
testSuite.run
|
62
|
+
```
|
63
|
+
|
64
|
+
## Now supports Action validation
|
65
|
+
|
66
|
+
You can now validate that the field that you clicked has valid data within it by simply setting the `:validate => true` flag within your Action.
|
67
|
+
|
68
|
+
If you don't want to then just don't set it.
|
69
|
+
|
70
|
+
# How to install Chrome Driver on Mac OSX
|
71
|
+
|
72
|
+
In order to control Chrome you will need to install the Chrome Driver please follow these steps.
|
73
|
+
https://www.swtestacademy.com/install-chrome-driver-on-mac/
|
74
|
+
|
75
|
+
Note once the driver is installed run it manually once in order to allow the system to trust it. If you do not do thisd then the system will not trust it and then it will not open
|
9
76
|
|
10
77
|
# How to install dependencies
|
11
78
|
|
@@ -18,10 +85,71 @@ Ruby Types are defined here: https://www.geeksforgeeks.org/ruby-data-types/
|
|
18
85
|
|
19
86
|
1. Make sure Ruby is installed `ruby -v` should return the current version of the language on your computer
|
20
87
|
2. Install bundler using `gem install bundler` to allow you to build the project
|
21
|
-
3. Building is as simple as `gem build
|
88
|
+
3. Building is as simple as `gem build legoTech.gemspec`
|
22
89
|
|
23
90
|
# How to publish
|
24
91
|
|
25
92
|
1. Make sure Ruby is installed `ruby -v` should return the current version of the language on your computer
|
26
93
|
2. Make sure you have a built gem
|
27
|
-
3. Using the gem command run the following `gem push [YOUR_GEM_NAME].gem`
|
94
|
+
3. Using the gem command run the following `gem push [YOUR_GEM_NAME].gem`
|
95
|
+
|
96
|
+
# How to include within project
|
97
|
+
|
98
|
+
**Using Bundler**
|
99
|
+
|
100
|
+
1. Install bundler
|
101
|
+
2. Create a Gemfile
|
102
|
+
3. Locate all the gem [here](https://rubygems.org/gems/legoTech_gem)
|
103
|
+
4. Include the version that you wish to use within the Gemfile
|
104
|
+
5. Add `selenium-webdriver` as a dependency to the Gemfile
|
105
|
+
6. Run `bundle install`
|
106
|
+
7. Create a ruby file called `example.rb`
|
107
|
+
8. At the top write `require "legoTech_gem"`
|
108
|
+
9. Run the following command `bundle exec ruby example.rb`
|
109
|
+
|
110
|
+
**Using pure Gem**
|
111
|
+
|
112
|
+
1. Make sure Ruby is installed
|
113
|
+
2. Run `gem install legoTech_gem`
|
114
|
+
3. Create a ruby file
|
115
|
+
4. At the top write `require "legoTech_gem"`
|
116
|
+
5. Run the file and all your dependencies should be there
|
117
|
+
|
118
|
+
# Run the Example
|
119
|
+
|
120
|
+
You can run the example script which would provide you with a nice and simple example of how the script works.
|
121
|
+
|
122
|
+
1. Install Selenium
|
123
|
+
2. Install Chrome Driver (shown above)
|
124
|
+
3. Install Ruby
|
125
|
+
4. Within the `e2e` folder run `ruby main.rb`
|
126
|
+
|
127
|
+
Before Result:
|
128
|
+
|
129
|
+

|
130
|
+
|
131
|
+
After Result:
|
132
|
+
|
133
|
+

|
134
|
+
|
135
|
+
# Author
|
136
|
+
|
137
|
+
[Patrique Legault](mailto:patrique.legault@gmail.com)
|
138
|
+
|
139
|
+
**Profile Links**
|
140
|
+
|
141
|
+
[Github](https://github.com/pat-lego)
|
142
|
+
|
143
|
+
[LinkedIn](https://www.linkedin.com/in/patrique-legault/)
|
144
|
+
|
145
|
+
[Twitter](https://twitter.com/_patlego)
|
146
|
+
|
147
|
+
# Notes
|
148
|
+
|
149
|
+
Please respect the naming definition as taken from here: https://github.com/airbnb/ruby#naming
|
150
|
+
|
151
|
+
Comments and tags must respect the naming from: https://rubydoc.info/gems/yard/file/docs/Tags.md
|
152
|
+
|
153
|
+
Ruby Types are defined here: https://www.geeksforgeeks.org/ruby-data-types/
|
154
|
+
|
155
|
+
**Note**: https://stackoverflow.com/questions/28506769/failed-to-require-a-local-gem/28507368#28507368
|
data/legoTech.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "legoTech_gem"
|
3
|
-
spec.version = "0.0.
|
3
|
+
spec.version = "0.0.5"
|
4
4
|
spec.authors = ["Patrique Legault"]
|
5
5
|
spec.email = ["patrique.legault@gmail.com"]
|
6
6
|
spec.summary = %q{A Ruby library used to test forms using browser automation}
|
data/lib/legoTech_gem.rb
CHANGED
data/lib/ui/actions/Action.rb
CHANGED
@@ -1,20 +1,93 @@
|
|
1
1
|
# @author Patrique Legault
|
2
|
+
|
3
|
+
require_relative "../enums/FieldType"
|
4
|
+
require_relative "../validate/ValidateElement"
|
5
|
+
|
2
6
|
module LegoTechSelenium
|
3
|
-
class
|
7
|
+
class Action
|
4
8
|
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @param driver [Driver] The driver object that represents the instance that is connected to the browser
|
9
|
+
# The constructor of the Action class
|
10
|
+
# @param driver [LegoTechSelenium::Driver] The driver object that represents the instance that is connected to the browser
|
8
11
|
# @param action [Hash] A ruby object that has the following layout
|
9
12
|
# {
|
10
|
-
# :
|
13
|
+
# :fieldtype => Fields::...
|
11
14
|
# :identifier => Identifier::...
|
12
15
|
# :value => String
|
16
|
+
# :validate => True -> Verify the value before continuing to the next action. False -> skip validation.
|
13
17
|
# }
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
def initialize(action, driver)
|
19
|
+
@driver = driver
|
20
|
+
@action = action
|
21
|
+
@wait = @driver.get_wait
|
22
|
+
@selenium_driver = @driver.get_selenium_driver
|
23
|
+
|
24
|
+
if @driver.nil?
|
25
|
+
raise "Cannot have a nil driver within the Action class"
|
26
|
+
end
|
27
|
+
|
28
|
+
if @action.nil? or @action.empty?
|
29
|
+
raise "Cannot have a nil or empty action hash within the Action class"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# A function that performs the given action against the webpage given the driver and the action
|
34
|
+
# @raise [RuntimeError] FieldType is not supported
|
35
|
+
def test()
|
36
|
+
element = @wait.until { @selenium_driver.find_element(@action[:identifier], @action[:fieldname]) }
|
37
|
+
|
38
|
+
case @action[:fieldtype]
|
39
|
+
when LegoTechSelenium::FieldType::INPUT
|
40
|
+
executeInput(element)
|
41
|
+
when LegoTechSelenium::FieldType::DROPDOWN_LIST
|
42
|
+
executeSelect(element)
|
43
|
+
when LegoTechSelenium::FieldType::BUTTON
|
44
|
+
executeButton(element)
|
45
|
+
when LegoTechSelenium::FieldType::CHECK_BOX
|
46
|
+
executeCheckBox(element)
|
47
|
+
when LegoTechSelenium::FieldType::RADIO_BUTTON
|
48
|
+
executeRadioButton(element)
|
49
|
+
else
|
50
|
+
raise "Could not locate the field type to perform the action on, received the following field #{@action[:fieldtype].downcase}. Currently only supports the fields within FieldType.rb"
|
51
|
+
end
|
52
|
+
|
53
|
+
if @action[:validate] == true
|
54
|
+
unless LegoTechSelenium::ValidateElement.new(@action, element).validate
|
55
|
+
raise "Failed to validate the #{@action[:fieldname]} is set to \"#{@action[:value]}\""
|
56
|
+
end
|
57
|
+
else
|
58
|
+
puts "Skipping assertion for #{self.class.name}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Perform the input exection on the element
|
63
|
+
# @param element [Selenium::WebDriver::Element]
|
64
|
+
def executeInput(element)
|
65
|
+
element.send_keys(@action[:value])
|
66
|
+
end
|
67
|
+
|
68
|
+
# Perform the input exection on the element
|
69
|
+
# @param element [Selenium::WebDriver::Element]
|
70
|
+
def executeSelect(element)
|
71
|
+
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
72
|
+
dropdown.select_by(:text, @action[:value])
|
73
|
+
end
|
74
|
+
|
75
|
+
# Perform the input exection on the element
|
76
|
+
# @param element [Selenium::WebDriver::Element]
|
77
|
+
def executeButton(element)
|
78
|
+
element.click
|
79
|
+
end
|
80
|
+
|
81
|
+
# Perform the check box exection on the element
|
82
|
+
# @param element [Selenium::WebDriver::Element]
|
83
|
+
def executeCheckBox(element)
|
84
|
+
element.click
|
85
|
+
end
|
86
|
+
|
87
|
+
# Perform the radio button exection on the element
|
88
|
+
# @param element [Selenium::WebDriver::Element]
|
89
|
+
def executeRadioButton(element)
|
90
|
+
element.click
|
18
91
|
end
|
19
92
|
end
|
20
93
|
end
|
data/lib/ui/driver/Driver.rb
CHANGED
@@ -2,33 +2,54 @@ require "selenium-webdriver"
|
|
2
2
|
|
3
3
|
# @author Patrique Legault
|
4
4
|
module LegoTechSelenium
|
5
|
-
class
|
6
|
-
@driver
|
7
|
-
|
5
|
+
class Driver
|
8
6
|
# Pass in an instance of the driver
|
9
7
|
# @param The driver from Selenium Webdriver class
|
10
8
|
def initialize(driver)
|
11
9
|
@driver = driver
|
10
|
+
@wait = Selenium::WebDriver::Wait.new(:timeout => 15)
|
12
11
|
end
|
13
12
|
|
14
13
|
# Set the amount of time the driver should wait when searching for elements.
|
15
14
|
# @param implicit_wait seconds for implicit wait
|
16
15
|
def set_implicit_wait(implicit_wait)
|
16
|
+
@driver.manage.timeouts.implicit_wait = implicit_wait
|
17
17
|
end
|
18
18
|
|
19
19
|
# Sets the amount of time to wait for a page load to complete before throwing an error.
|
20
20
|
# @param page_load seconds to wait for page to load
|
21
21
|
def set_page_load(page_load)
|
22
|
+
@driver.manage.timeouts.page_load = page_load
|
22
23
|
end
|
23
24
|
|
24
25
|
# Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error.
|
25
26
|
# @param script_time seconds to wait for script to complete
|
26
|
-
def
|
27
|
+
def set_script_timeout(script_timeout)
|
28
|
+
@driver.manage.timeouts.script_timeout = script_timeout
|
27
29
|
end
|
28
30
|
|
29
31
|
# The URL to navigate to
|
30
32
|
# @param navigate_to location for the browser to navigate to
|
31
33
|
def set_navigate_to(navigate_to)
|
34
|
+
@driver.navigate.to(navigate_to)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Function used to override the overall wait in order to find an element within the DOM
|
38
|
+
# @param wait_time [Number] represents how long to wait until an error is thrown
|
39
|
+
def set_element_find_wait(wait_time)
|
40
|
+
@wait = Selenium::WebDriver::Wait.new(:timeout => wait_time)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Function used to get the wait object
|
44
|
+
# @return [Selenium::WebDriver::Wait] Wait object that does a wait for the object to appear in the DOM
|
45
|
+
def get_wait
|
46
|
+
@wait
|
47
|
+
end
|
48
|
+
|
49
|
+
# Function used to get the Selenium WebDriver
|
50
|
+
# @return [Selenium::WebDriver] Selenium webdriver
|
51
|
+
def get_selenium_driver
|
52
|
+
@driver
|
32
53
|
end
|
33
54
|
end
|
34
55
|
end
|
data/lib/ui/enums/Identifier.rb
CHANGED
@@ -1,12 +1,74 @@
|
|
1
|
+
require_relative "../actions/Action"
|
2
|
+
|
1
3
|
# @author Patrique Legault
|
2
4
|
module LegoTechSelenium
|
3
5
|
class TestCase
|
4
|
-
def initialize(name)
|
6
|
+
def initialize(name, driver)
|
5
7
|
if name.nil? or name.empty?
|
6
8
|
raise "All TestCasses must have a name associated to them"
|
7
9
|
end
|
8
10
|
|
11
|
+
if driver.nil?
|
12
|
+
raise "The driver is nil in the TestCase"
|
13
|
+
end
|
9
14
|
@name = name
|
15
|
+
@driver = driver
|
16
|
+
|
17
|
+
@actions = []
|
18
|
+
end
|
19
|
+
|
20
|
+
# Function used to add an action to the list of actions to later be invoked
|
21
|
+
# @param action [Action] an object that represents a list of events to invoke
|
22
|
+
# @return nil
|
23
|
+
def add_action(action)
|
24
|
+
if action.nil?
|
25
|
+
raise "Cannot pass a nil action to TestCase"
|
26
|
+
end
|
27
|
+
|
28
|
+
unless action.class.superclass.name.eql? ("LegoTechSelenium::Action")
|
29
|
+
raise "action is not an instance of LegoTechSelenium::Action within TestCase"
|
30
|
+
end
|
31
|
+
@actions.push(action)
|
32
|
+
return nil
|
33
|
+
end
|
34
|
+
|
35
|
+
# Function used to get the name of the Test Case instance
|
36
|
+
# @return [String] Name of the Test Case Instance
|
37
|
+
def get_name()
|
38
|
+
@name
|
39
|
+
end
|
40
|
+
|
41
|
+
# Function get the number of actions within the TestCase
|
42
|
+
# [Number] The number of actions within the TestCase
|
43
|
+
def get_number_of_actions()
|
44
|
+
@actions.size
|
45
|
+
end
|
46
|
+
|
47
|
+
# Function used to invoke all of the actions within the list
|
48
|
+
def run()
|
49
|
+
@actions.each do |action|
|
50
|
+
action.test()
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Builder
|
55
|
+
def initialize(name, driver)
|
56
|
+
@testCase = TestCase.new(name, driver)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Function used to add an action using a Builder class
|
60
|
+
# @param action [Action] The action to add to the list of actions
|
61
|
+
# @return [Builder] the Builder class
|
62
|
+
def add_action(action)
|
63
|
+
@testCase.add_action(action)
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
# A function the return the built TestCase
|
68
|
+
# @return [TestCase] The built TestCase
|
69
|
+
def build
|
70
|
+
@testCase
|
71
|
+
end
|
10
72
|
end
|
11
73
|
end
|
12
74
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "../test-cases/TestCase"
|
2
|
+
|
1
3
|
# @author Patrique Legault
|
2
4
|
module LegoTechSelenium
|
3
5
|
class TestSuite
|
@@ -13,30 +15,39 @@ module LegoTechSelenium
|
|
13
15
|
end
|
14
16
|
@name = name
|
15
17
|
@driver = driver
|
16
|
-
@
|
18
|
+
@testCases = []
|
17
19
|
end
|
18
20
|
|
19
21
|
# Function used to add a TestCase to thee TestSuite
|
20
22
|
# @param testCase [TestCase] A test case to be executed
|
21
|
-
def
|
22
|
-
|
23
|
+
def add_test_case(testCase)
|
24
|
+
if testCase.nil?
|
25
|
+
raise "Cannot have nil testCase within TestSuite"
|
26
|
+
end
|
27
|
+
|
28
|
+
unless testCase.instance_of? LegoTechSelenium::TestCase
|
29
|
+
raise "testCase is not an instance of TestCase within the TestSuite"
|
30
|
+
end
|
31
|
+
@testCases.push(testCase)
|
23
32
|
end
|
24
33
|
|
25
34
|
# Retrieve the name of the TestSuite
|
26
35
|
# @return [String] The name of the TestSuite
|
27
|
-
def
|
36
|
+
def get_name()
|
28
37
|
return @name
|
29
38
|
end
|
30
39
|
|
31
40
|
# Retrieve the number of TestCases within the TestSuite
|
32
41
|
# @return [Number] Number of TestCases
|
33
|
-
def
|
34
|
-
return @
|
42
|
+
def get_number_of_test_cases
|
43
|
+
return @testCases.size
|
35
44
|
end
|
36
45
|
|
37
46
|
# Function that will invoke all test cases
|
38
47
|
def run()
|
39
|
-
|
48
|
+
@testCases.each do |testCase|
|
49
|
+
testCase.run()
|
50
|
+
end
|
40
51
|
end
|
41
52
|
|
42
53
|
class Builder
|
@@ -50,8 +61,8 @@ module LegoTechSelenium
|
|
50
61
|
# Add a test case to the test suite
|
51
62
|
# @param TestsCase [TestCase] to be added to the list
|
52
63
|
# @return self
|
53
|
-
def
|
54
|
-
@testSuites.
|
64
|
+
def add_test_case(testCase)
|
65
|
+
@testSuites.add_test_case(testCase)
|
55
66
|
self
|
56
67
|
end
|
57
68
|
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require_relative "../enums/FieldType"
|
2
|
+
|
3
|
+
module LegoTechSelenium
|
4
|
+
class ValidateElement
|
5
|
+
|
6
|
+
# The constructor of the Action class
|
7
|
+
# @param element [Selenium::WebDriver::Element]
|
8
|
+
# @param action [Hash] A ruby object that has the following layout
|
9
|
+
# {
|
10
|
+
# :fieldtype => Fields::...
|
11
|
+
# :identifier => Identifier::...
|
12
|
+
# :value => String
|
13
|
+
# :validate => True -> Verify the value before continuing to the next action, skip validation
|
14
|
+
# }
|
15
|
+
def initialize(action, element)
|
16
|
+
if action.nil? or action.empty?
|
17
|
+
raise "Cannot submit a nil or empty action within the Validate class"
|
18
|
+
end
|
19
|
+
|
20
|
+
if element.nil?
|
21
|
+
raise "Cannot submit a nil Selenium element within the Validate class"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Set instance variables
|
25
|
+
@action = action
|
26
|
+
@element = element
|
27
|
+
end
|
28
|
+
|
29
|
+
# Function used to validate the element is correctly set
|
30
|
+
# @return True if correctly validated, False if incorrectly validated
|
31
|
+
# @raise [RuntimeError] FieldType is not supported
|
32
|
+
def validate()
|
33
|
+
case @action[:fieldtype]
|
34
|
+
when LegoTechSelenium::FieldType::INPUT
|
35
|
+
return validateInput
|
36
|
+
when LegoTechSelenium::FieldType::DROPDOWN_LIST
|
37
|
+
return validateSelect
|
38
|
+
when LegoTechSelenium::FieldType::BUTTON
|
39
|
+
# Cannot validate the value of a button
|
40
|
+
return true
|
41
|
+
when LegoTechSelenium::FieldType::CHECK_BOX
|
42
|
+
return validateCheckBox
|
43
|
+
when LegoTechSelenium::FieldType::RADIO_BUTTON
|
44
|
+
return validateRadioButton
|
45
|
+
else
|
46
|
+
raise "Cannot validate this field type please refer to the validate function within the Validate class for further details"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Validates the value of an input field
|
51
|
+
# return True -> action value is equal to the input field value
|
52
|
+
def validateCheckBox()
|
53
|
+
puts "Asserting that #{LegoTechSelenium::FieldType::INPUT} with field name #{@action[:fieldname]} is set to \"#{@action[:value]}\""
|
54
|
+
unless @action[:value].nil?
|
55
|
+
return @action[:value].eql? @element.attribute("value")
|
56
|
+
else
|
57
|
+
return @action[:fieldname].eql? @element.attribute("value")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Validates the value of an input field
|
62
|
+
# return True -> action value is equal to the input field value
|
63
|
+
def validateRadioButton()
|
64
|
+
puts "Asserting that #{LegoTechSelenium::FieldType::INPUT} with field name #{@action[:fieldname]} is set to \"#{@action[:value]}\""
|
65
|
+
unless @action[:value].nil?
|
66
|
+
return @action[:value].eql? @element.attribute("value")
|
67
|
+
else
|
68
|
+
return @action[:fieldname].eql? @element.attribute("value")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Validates the value of an input field
|
73
|
+
# return True -> action value is equal to the input field value
|
74
|
+
def validateInput()
|
75
|
+
puts "Asserting that #{LegoTechSelenium::FieldType::INPUT} with field name #{@action[:fieldname]} is set to \"#{@action[:value]}\""
|
76
|
+
return @action[:value].eql? @element.attribute("value")
|
77
|
+
end
|
78
|
+
|
79
|
+
# Validates the value of an input field
|
80
|
+
# return True -> action value is equal to the input field value
|
81
|
+
def validateSelect()
|
82
|
+
puts "Asserting that #{LegoTechSelenium::FieldType::DROPDOWN_LIST} with field name #{@action[:fieldname]} is set to \"#{@action[:value]}\""
|
83
|
+
return @action[:value].eql? Selenium::WebDriver::Support::Select.new(@element).first_selected_option.text
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legoTech_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrique Legault
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,10 +52,11 @@ files:
|
|
52
52
|
- lib/legoTech_gem.rb
|
53
53
|
- lib/ui/actions/Action.rb
|
54
54
|
- lib/ui/driver/Driver.rb
|
55
|
-
- lib/ui/enums/
|
55
|
+
- lib/ui/enums/FieldType.rb
|
56
56
|
- lib/ui/enums/Identifier.rb
|
57
57
|
- lib/ui/test-cases/TestCase.rb
|
58
58
|
- lib/ui/test-suites/TestSuite.rb
|
59
|
+
- lib/ui/validate/ValidateElement.rb
|
59
60
|
homepage: https://www.pat-lego.io
|
60
61
|
licenses:
|
61
62
|
- MIT
|