page-object-lds 0.0.12 → 0.0.13

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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 627d2e3cd8eb0cdbb8cb2a719ad6cecb35f897a8
4
- data.tar.gz: d140a01fb7da842b755a28fd3a705c7c324b1aba
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTY4MzM1NzEwN2I4NDVmNTMyMTk0NTQ1ODEwNGMxNDhmODk0MGU3Ng==
5
+ data.tar.gz: !binary |-
6
+ ODAyMDUyMWEyYjUwMTNiMjI4ZWI2YjhkYmZlNDdmYjQ1YmFkZGQxYw==
5
7
  SHA512:
6
- metadata.gz: f4c7e480eb62131b53f7258b513c6c2f6d8da4439f8dccf497d910d3e30b5bef4ab60ec903cc8b380aec4fe4e622f8824f926f8993da4d5674d72b813c735741
7
- data.tar.gz: d71c0506ddb6ace350c27339dd69dc0af2b24473bb468a480b7a0324d0f806e578b5a907cdd27ea01603bbb38cfc1dd1cc7285599de9fda2891d40ea77240ff1
8
+ metadata.gz: !binary |-
9
+ MjMyY2Q0MTY3MDAwYThlZGY4NjgwNjVmNDE1MTNhZjQ0MDE1ODAzMTJlNDgw
10
+ YTNhMjViNWQxMDBlZmVhYTM4YTViZGM4NGQ5ZmNhMDkzN2I4YTdkN2Y4NzBi
11
+ ZTEwM2Q0NzNkY2MxZWQwMDk2Mzg4ZGIxOGYxOWE2M2I0ZjRkODM=
12
+ data.tar.gz: !binary |-
13
+ ODk0OWRlM2Q2NDUzMzIxMWYzMzdmZTU2ZTk4MWZhNDZkYjdlYzE1ZTVhYWVl
14
+ MzgxMzA1N2E4ZmM1ZGYxOTA2YjgwNTcwZTcyYTYzMjVjMjBkZjcxMDNmYzQ2
15
+ N2NhMWFmOWQwYzdhYTYyNGM4N2FjNWMxOTljMGRjNTYyODkzNGU=
@@ -0,0 +1,47 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/TNR360/components/dependencies.rb')
2
+ ENV['no_proxy'] = '127.0.0.1'
3
+ class ServerUtils
4
+ @borwser
5
+
6
+
7
+ #constructor
8
+ def initialize()
9
+ @borwser=browser_create(:firefox)
10
+ end
11
+
12
+ def connectToDemoServer
13
+ login( "http://ekipv7:9192/ekip360-gui-ws/Ekip.html", "ekip","ekip.360")
14
+ @borwser
15
+ end
16
+
17
+
18
+ def browser_create(version)
19
+ # :chrome, :ie, or :ff
20
+ if(version==:firefox)
21
+ profile = Selenium::WebDriver::Firefox::Profile.new
22
+ profile.native_events = false
23
+ #Watir::Browser.new WEB_DRIVER, :profile => profile
24
+ @browser ||= Watir::Browser.new version, :profile => profile
25
+ else
26
+ @browser ||= Watir::Browser.new(version)
27
+ end
28
+
29
+ #@browser.driver.manage.timeouts.implicit_wait=3
30
+ @browser
31
+ end
32
+
33
+
34
+
35
+
36
+
37
+ def login(url,username, password)
38
+ @browser.goto url
39
+ @browser.driver.manage.window.maximize
40
+ @browser.text_field(:name => "j_username").when_present.set(username)
41
+ @browser.text_field(:name => "j_password").when_present.set(password )
42
+ @browser.button(:value, "Connection").when_present.click
43
+ end
44
+
45
+
46
+
47
+ end
@@ -0,0 +1,5 @@
1
+ begin
2
+ #just close headless if it has been opened
3
+ @headless.destroy
4
+ rescue
5
+ end
@@ -0,0 +1,20 @@
1
+
2
+
3
+ gem "minitest"
4
+ require 'minitest/autorun'
5
+ require 'watir-webdriver'
6
+ require 'cucumber'
7
+
8
+ #Load config files
9
+ require File.expand_path(File.dirname(__FILE__) + '/TnrUtilsMehdi.rb')
10
+ require File.expand_path(File.dirname(__FILE__) + '/components/dependencies.rb')
11
+
12
+ #If running on linux, we only run on Headless mode (Xvfb)
13
+ if !Gem.win_platform?
14
+ require 'headless'
15
+ headless = Headless.new
16
+ headless.start
17
+ at_exit do
18
+ headless.destroy
19
+ end
20
+ end
@@ -0,0 +1,61 @@
1
+ require 'minitest/autorun'
2
+ require 'watir-webdriver'
3
+ # The no proxy is needed for webdriver to not use the HTTP_PROXY if it is set in
4
+ # the environment
5
+ ENV['no_proxy'] = '127.0.0.1'
6
+
7
+
8
+ def browser(version)
9
+ # :chrome, :ie, or :ff
10
+ @browser ||= Watir::Browser.new(version)
11
+ @browser.driver.manage.timeouts.implicit_wait=3
12
+ @browser
13
+ end
14
+ def login(url,username, password)
15
+
16
+
17
+ @browser.goto url
18
+ @browser.driver.manage.window.maximize
19
+
20
+ @browser.text_field(:name => "j_username").when_present.set(username)
21
+ @browser.text_field(:name => "j_password").when_present.set(password )
22
+ @browser.button(:value, "Connection").when_present.click
23
+ end
24
+
25
+ def goToDas2Closure
26
+ @browser.a(:text => "Interfaces").when_present(60).click
27
+ @browser.button(:value,"DAS2").when_present.click
28
+ @browser.link(:text, "New DAS2 closure").when_present.click
29
+ end
30
+
31
+ def goToAssetSearch
32
+ @browser.button(:text , "Asset search".split('/').take(1).first).when_present.click
33
+ @browser.button(:value,"Search").when_present.click#
34
+ end
35
+
36
+ def goToPartyContractSearch
37
+ @browser.button(:text , "Party contract search".split('/').take(1).first).when_present.click
38
+ @browser.button(:value, "Search").when_present.click#
39
+ end
40
+
41
+ def goToPaymentSearch
42
+ @browser.button(:text , "Payment search".split('/').take(1).first).when_present.click
43
+ @browser.button(:value, "Search").when_present.click#
44
+ end
45
+
46
+ def goToContractElementsExpiringSearch
47
+ @browser.a(:text => "Parties and Contracts").when_present(60).click
48
+ @browser.button(:value,"Contract elements expiring search").when_present.click
49
+ end
50
+
51
+ def goToContractPopulation
52
+ @browser.a(:text => "Fleet management").when_present(60).click
53
+ @browser.button(:value,"Contract population search").when_present.click
54
+ @browser.button(:value, "Search").when_present.click#
55
+ end
56
+
57
+ def goToWeeksAndMonthsConfiguration
58
+ @browser.a(:text => "Setup").when_present(60).click
59
+ @browser.table(:id,"x-auto-165").button(:class,"x-btn-text").click
60
+ @browser.link(:text, "Configuration of week's days and year's months").when_present.click
61
+ end
@@ -0,0 +1,91 @@
1
+ #Configurable wait time, in seconds
2
+ $wait_time=10
3
+
4
+ $small_wait_time=2
5
+
6
+ $large_wait_time=40
7
+
8
+ #method to replace nil with an empty string
9
+ def no_null obj
10
+ ((obj==nil) ? '' : obj)
11
+ end
12
+
13
+ #method to replace nil with false string
14
+ def bool_no_null obj
15
+ ((obj==nil) ? 'false' : obj)
16
+ end
17
+
18
+ def custom_double_click brwser,elmnt
19
+ if (brwser.driver.browser.to_s =='firefox')
20
+ elmnt.when_present.fire_event("ondblclick")
21
+ else
22
+ elmnt.when_present.double_click
23
+ end
24
+ end
25
+
26
+ #find a parent class with a class containing expression
27
+ def findParentWithClass parent_class_name,current_element
28
+ found=false
29
+ element=nil
30
+ previousElement=nil
31
+ while (!found)
32
+ if (element==nil)
33
+ tempElement= element=previousElement=current_element.parent
34
+ else
35
+ previousElement=element
36
+ tempElement=element.parent
37
+ end
38
+
39
+ if (tempElement.class_name.include? parent_class_name)
40
+ found=true
41
+ end
42
+ element=tempElement
43
+ end
44
+ return element, previousElement
45
+ end
46
+
47
+
48
+ #find a parent class with a id containing expression
49
+ def findParentWithId parent_idElement,current_element
50
+ found=false
51
+ element=nil
52
+ previousElement=nil
53
+ while (!found)
54
+ if (element==nil)
55
+ tempElement= element=previousElement=current_element.parent
56
+ else
57
+ previousElement=element
58
+ tempElement=element.parent
59
+ end
60
+
61
+ if (tempElement.id.include? parent_idElement)
62
+ found=true
63
+ end
64
+ element=tempElement
65
+ end
66
+ return element, previousElement
67
+ end
68
+
69
+ def force_find_element block
70
+ found_element=false
71
+ retries_left = 3
72
+ begin
73
+ found_element= block.call
74
+ rescue Timeout::Error
75
+ puts("Caught a TIMEOUT ERROR!")
76
+
77
+ # You may want to wait for a while before retrying.
78
+ sleep(3)
79
+
80
+ # Retry the code that generates the exception.
81
+ retries_left -= 1
82
+ retry if retries_left > 0
83
+
84
+ # No more retries left - time to bail out! Re-raise the exception.
85
+ raise
86
+ end
87
+ found_element
88
+ end
89
+
90
+
91
+
@@ -0,0 +1,48 @@
1
+ require 'minitest/autorun'
2
+ require 'watir-webdriver'
3
+ # The no proxy is needed for webdriver to not use the HTTP_PROXY if it is set in
4
+ # the environment
5
+ ENV['no_proxy'] = '127.0.0.1'
6
+
7
+
8
+ def browser(version)
9
+ # :chrome, :ie, or :ff
10
+ @browser ||= Watir::Browser.new(version)
11
+ @browser.driver.manage.timeouts.implicit_wait=3
12
+ @browser
13
+ end
14
+ def login(url,username, password)
15
+ # TODO: Make login id configurable, make URL configurable
16
+ # browser().goto "http://vmdemo:8992/ekip-gui-standard/login.jsp#ekip"
17
+
18
+ @browser.goto url
19
+ @browser.driver.manage.window.maximize
20
+
21
+ @browser.text_field(:name => "j_username").when_present.set(username)
22
+ @browser.text_field(:name => "j_password").when_present.set(password )
23
+ @browser.button(:value, "Connection").when_present.click
24
+ end
25
+
26
+ def goToDas2Closure
27
+ @browser.a(:text => "Interfaces").when_present(60).click#TODO:groupe menu /root title
28
+ @browser.button(:value,"DAS2").when_present.click#TODO:liste menu
29
+ @browser.link(:text, "DAS2 closure search").when_present.click#TODO:main menu button
30
+ end
31
+
32
+ def goToInvoiceSearch
33
+
34
+ @browser.a(:text => "Main").when_present(60).click#TODO:groupe menu /root title
35
+ @browser.link(:value,"Invoice search").when_present.click#TODO:liste menu
36
+
37
+ end
38
+
39
+ def doubleClick
40
+ #@@browser.
41
+ @browser.div(:class => "fwk-result-managementCompany").when_present.double_click
42
+ end
43
+
44
+ def click
45
+ #@@browser.
46
+ #$browser.div(:class => "fwk-result-contractIe").when_present.double_click
47
+ @browser.button(:text => "Search").when_present.click
48
+ end
@@ -0,0 +1,35 @@
1
+ require 'minitest/autorun'
2
+ require 'watir-webdriver'
3
+ # The no proxy is needed for webdriver to not use the HTTP_PROXY if it is set in
4
+ # the environment
5
+
6
+
7
+
8
+
9
+ def goToPartyContractSearch browser
10
+ browser.a(:text => "Main").when_present(60).click#TODO:groupe menu /root title
11
+ browser.button(:value,"Party contract search").when_present.click
12
+ end
13
+
14
+ def goToDas2Closure browser
15
+ browser.a(:text => "Interfaces").when_present(60).click#TODO:groupe menu /root title
16
+ browser.button(:value,"DAS2").when_present.click#TODO:liste menu
17
+ browser.link(:text, "DAS2 closure search").when_present.click#TODO:main menu button
18
+ end
19
+
20
+
21
+ def goToInvoiceSearch browser
22
+ browser.a(:text => "Main").when_present(60).click#TODO:groupe menu /root title
23
+ browser.link(:value,"Invoice search").when_present.click
24
+
25
+ end
26
+
27
+ def doubleClick browser
28
+ custom_double_click browser, browser.div(:class => "fwk-result-managementCompany")
29
+ end
30
+
31
+ def click browser
32
+ #@@browser.
33
+ #$browser.div(:class => "fwk-result-contractIe").when_present.double_click
34
+ browser.button(:text => "Search").when_present.click
35
+ end
@@ -0,0 +1,21 @@
1
+ gem "minitest"
2
+ require "minitest/autorun"
3
+ require 'watir-webdriver'
4
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_text_field.rb')
5
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_block.rb')
6
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_fk.rb')
7
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_lov.rb')
8
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_area.rb')
9
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_column.rb')
10
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_grid.rb')
11
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_screen.rb')
12
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_checkbox.rb')
13
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_radio.rb')
14
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_menu.rb')
15
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_action.rb')
16
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/lds_summary_view.rb')
17
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/block_in_summary_view')
18
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/ServerUtils')
19
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/Firefox')
20
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/Chrome')
21
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/TnrUtilsGeneric')
@@ -0,0 +1,62 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/dependencies.rb')
2
+ class LdsAction
3
+ @browser
4
+ @idScreen=nil
5
+ @action_text=nil
6
+ @exists=false
7
+ @clickedAction
8
+ @current_element
9
+ #constructor
10
+ def initialize(browser,action_text,idScreen=nil)
11
+ @browser =browser
12
+ @action_text=action_text
13
+ @idScreen=idScreen
14
+ @exists
15
+ end
16
+
17
+ def click
18
+ action_path = @action_text.split('/')
19
+ raise "Provide at least one level of action item" if (action_path.length < 1)
20
+ for i in 0..(action_path.length-1)
21
+ puts "Value of local variable is #{i}"
22
+ case i
23
+ when 0
24
+ @browser.table(:id => action_path[i]).button.when_present.click
25
+ sleep($small_wait_time)
26
+ when 1
27
+ @browser.a(:id=> action_path[i]).when_present.click
28
+ sleep($small_wait_time)
29
+
30
+ when i==action_path.length-1
31
+ @browser.a(:id=>action_path[i]).when_present.click
32
+ sleep($small_wait_time)
33
+ else
34
+ @browser.a(:id=>action_path[i]).when_present.hover
35
+ sleep($small_wait_time)
36
+ if i==action_path.length-1
37
+ @browser.a(:id=>action_path[i]).when_present.click
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ #print object
44
+ def to_s
45
+ "\n***** Button *****"+
46
+ "\nAction text : "+ no_null(@action_text)+
47
+ "\nIdScreen : "+ no_null(@IdScreen) +
48
+ "\nExists : "+ no_null(@exists.to_s)+
49
+ "\n**********"
50
+ end
51
+ ####Getters
52
+ def getIdScreen
53
+ @idScreen
54
+ end
55
+
56
+ def isExist?
57
+ @exists
58
+ end
59
+ end
60
+
61
+
62
+
@@ -0,0 +1,171 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../lib/TNR360/components/dependencies.rb')
2
+
3
+ class LdsArea
4
+
5
+ @browser
6
+ @parentBlock
7
+ @idArea=nil
8
+ @title=nil
9
+ @visible=false
10
+ @exists=false
11
+ @collapsible=false
12
+ @collapsed=false
13
+ @current_element
14
+
15
+
16
+ #constructor
17
+ def initialize(browser, idArea, block=nil)
18
+ @browser =browser
19
+ @idArea=idArea
20
+ @parentBlock=block
21
+ update
22
+ @exists
23
+ end
24
+
25
+
26
+ #refresh object status from browser
27
+ def refresh
28
+ #Look for element in browser
29
+ @current_element= findElement @idArea
30
+ #update other data
31
+ update
32
+ @exists
33
+ end
34
+
35
+ #private method to update/save the status of the object
36
+ def update
37
+ @exists=false
38
+
39
+ #Look for element in browser
40
+ @current_element||= findElement @idArea
41
+
42
+ #fill @title
43
+ @title=@current_element.legend(:index => 0).span(:index => 0).text
44
+ #fill visible
45
+ @visible=@current_element.visible?
46
+ #fill isCollapsible
47
+ if @current_element.legend(:index => 0).divs.length>0
48
+ @collapsible=true
49
+ else
50
+ @collapsible=false
51
+ end
52
+ #fill isCollapsed
53
+ if @collapsible
54
+ @collapsed=@current_element.class_name.include? "collapsed"
55
+ else
56
+ @collapsed=false
57
+ end
58
+
59
+ #everything exists
60
+ @exists=true
61
+ end
62
+
63
+ #method locate current element
64
+ def findElement idElement
65
+ begin
66
+ #if element not yet available in screen, wait for some time
67
+ if @parentBlock != nil
68
+ @parentBlock.getElement.div(:index => 2).fieldset(:id, idElement).wait_until_present(10)
69
+ @current_element=@parentBlock.getElement.div(:index => 2).fieldset(:id, idElement)
70
+ end
71
+ rescue
72
+
73
+ raise "Element "+idElement+" Not Found"
74
+
75
+ ensure
76
+ #rien dans finally pour ce cas
77
+ if @parentBlock == nil
78
+ if @browser.fieldset(:id, idElement).wait_until_present(10)
79
+ count=@browser.fieldsets(:id, idElement).length
80
+ end
81
+ if count==0
82
+ raise "Element "+idElement+" Not Found"
83
+ else
84
+ if count >1
85
+ raise "Several Elements with id "+idElement+" Found, specify block"
86
+ end
87
+ end
88
+ @current_element=@browser.fieldset(:id, idElement).when_present
89
+ end
90
+ end
91
+ @current_element
92
+ end
93
+
94
+
95
+ #print object
96
+ def to_s
97
+ "\n***** Area *****"+
98
+ "\nIdArea : "+ no_null(@idArea)+
99
+ "\nIdParentBlock : "+(no_null(@parentBlock)=="" ? "" : @parentBlock.getIdBlock)+
100
+ "\nTitle : "+ no_null(@title)+
101
+ "\nCollapsible :"+ bool_no_null(@collapsible.to_s)+
102
+ "\nCollapsed :"+ bool_no_null(@collapsed.to_s)+
103
+ "\nVisible : "+ bool_no_null(@visible.to_s)+
104
+ "\nExists : "+ bool_no_null(@exists.to_s)+
105
+ "\n**********"
106
+ end
107
+
108
+
109
+ ##LdsScreen Actions
110
+ def reverse_collapse
111
+ if (@collapsible)
112
+ @current_element.legend(:index => 0).div(:index => 0).when_present.click
113
+ end
114
+ update
115
+ end
116
+
117
+ def collapse
118
+ if (@collapsible && !@collapsed)
119
+ @current_element.legend(:index => 0).div(:index => 0).when_present.click
120
+ end
121
+ update
122
+ end
123
+
124
+ def expand
125
+ if (@collapsible && @collapsed)
126
+ @current_element.legend(:index => 0).div(:index => 0).when_present.click
127
+ end
128
+ update
129
+ end
130
+
131
+ ####Getters
132
+
133
+ def getElement
134
+ @current_element
135
+ end
136
+
137
+ def getIdArea
138
+ @idArea
139
+ end
140
+
141
+ def getParentBloc
142
+ @parentBlock
143
+ end
144
+
145
+ def getTitle
146
+ @title
147
+ end
148
+
149
+ def isCollapsible?
150
+ @collapsible
151
+ end
152
+
153
+ def isCollapsed?
154
+ @collapsed
155
+ end
156
+
157
+ def isVisible?
158
+ @visible
159
+ end
160
+
161
+ def isExist?
162
+ @exists
163
+ end
164
+
165
+ #private method list
166
+ private :update
167
+ end
168
+
169
+
170
+
171
+