leap_salesforce_ui 0.1.7 → 0.3.0
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/.gitlab-ci.yml +14 -1
- data/.leap_salesforce.yml +1 -0
- data/ChangeLog +19 -0
- data/README.md +26 -1
- data/Rakefile +1 -0
- data/install_chrome.sh +6 -0
- data/leap_salesforce_ui.gemspec +2 -2
- data/lib/leap_salesforce_ui/base_page.rb +3 -1
- data/lib/leap_salesforce_ui/create_page.rb +2 -0
- data/lib/leap_salesforce_ui/form_filler.rb +1 -1
- data/lib/leap_salesforce_ui/login_page.rb +11 -1
- data/lib/leap_salesforce_ui/set_record_type.rb +12 -0
- data/lib/leap_salesforce_ui/version.rb +1 -1
- data/lib/leap_salesforce_ui.rb +5 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e1be86926699d819e7022902b56f15ac1b8bdf1e57a66558a26c4cfc5a2285d
|
4
|
+
data.tar.gz: 6b590aa9a06d618c77e55280b56903b92ed8eeb5a6bf1f550bd91575f8e25c96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9f507fcef6ccc42efebaa071ca82c23d2da3647a3b2320269a42c02f226e1d3d2497212ae7192e4a27c002045e3b2223cdbcba37fcdd548a50a183b5b1fa756
|
7
|
+
data.tar.gz: 3c49e8e58f6101fc3cd1bf7f378c93d4490de36a5893af083a43b702f6f288419d0772c9a4185f30bf04e5556ddf5e25905acfbe5ca6226765ff744d41e22cf4
|
data/.gitlab-ci.yml
CHANGED
@@ -3,7 +3,7 @@ variables:
|
|
3
3
|
client_id: $client_id
|
4
4
|
client_secret: $client_secret
|
5
5
|
|
6
|
-
|
6
|
+
.zal_test:
|
7
7
|
services:
|
8
8
|
- docker:19.03.5-dind
|
9
9
|
image: docker:19.03.5
|
@@ -24,5 +24,18 @@ test:
|
|
24
24
|
variables:
|
25
25
|
BROWSER: chrome
|
26
26
|
|
27
|
+
test:
|
28
|
+
image: ruby:2.7
|
29
|
+
script:
|
30
|
+
- export CHROME_VERSION="google-chrome-stable"
|
31
|
+
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
|
32
|
+
- echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
|
33
|
+
- apt-get update -qqy
|
34
|
+
- apt-get -qqy install google-chrome-stable
|
35
|
+
|
36
|
+
- bundle install
|
37
|
+
- bundle exec rake leaps:create_poms
|
38
|
+
- bundle exec rake spec
|
39
|
+
|
27
40
|
include:
|
28
41
|
- template: Code-Quality.gitlab-ci.yml
|
data/.leap_salesforce.yml
CHANGED
data/ChangeLog
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
Version 0.3.0
|
2
|
+
* New
|
3
|
+
* Ability to set record type on creating an object with 'set_record_type' method
|
4
|
+
* Fixed
|
5
|
+
* New syntax for clicking on dropdown/picklist
|
6
|
+
|
7
|
+
Version 0.2.0
|
8
|
+
* Pass in security token defined by leap_salesforce with convention ENV['KEY'_token] to SOAP
|
9
|
+
session login
|
10
|
+
|
11
|
+
Version 0.1.9
|
12
|
+
* Ability to login through SOAP session with the LeapSalesforce.login_through_session parameter
|
13
|
+
|
14
|
+
Version 0.1.8
|
15
|
+
* Fixed Watir version at 6.19. Need to update syntax to work with latest version
|
16
|
+
|
17
|
+
Version 0.1.7
|
18
|
+
* Fixed filling in form for Salesforce's new layout
|
19
|
+
|
1
20
|
Version 0.1.6
|
2
21
|
* Bug fix
|
3
22
|
* Not appending to Gemfile meant Rakefile could not load leap_salesfore_ui rake tasks
|
data/README.md
CHANGED
@@ -100,13 +100,21 @@ RSpec.describe "Creating record" do
|
|
100
100
|
end
|
101
101
|
```
|
102
102
|
|
103
|
-
One
|
103
|
+
One does not have to identify how to recognise first_name, last_name, etc.
|
104
104
|
From the metadata it works out what kind of field (textfield, textarea, reference) and then
|
105
105
|
finds the corresponding label and uses that to fill in the field.
|
106
106
|
|
107
107
|
This test then uses the API to setup a dependent account (through FactoryBot) and then to find the contact
|
108
108
|
created to verify that what was entered on the UI was saved as expected.
|
109
109
|
|
110
|
+
To specify a record_type, call the `set_record_type` method after the `visit` method.
|
111
|
+
The default record type can be used by calling visit with
|
112
|
+
```ruby
|
113
|
+
visit(use_record_type: false)
|
114
|
+
```
|
115
|
+
|
116
|
+
> See create spec for example
|
117
|
+
|
110
118
|
### Manually specify label
|
111
119
|
|
112
120
|
Sometimes the label on the UI does not match the metadata label. In that case, one case manually
|
@@ -132,6 +140,23 @@ To run tests in headless mode, set headless mode to true.
|
|
132
140
|
LeapSalesforce.headless = true
|
133
141
|
```
|
134
142
|
|
143
|
+
### Authentication
|
144
|
+
If IP address for user profile is not allowed you will need to use a security token. See
|
145
|
+
leap_salesforce for how to set this for each user's key through environment variables.
|
146
|
+
|
147
|
+
### Helpful commands
|
148
|
+
|
149
|
+
Go to Salesforce instance defined by logging in
|
150
|
+
```ruby
|
151
|
+
LeapSalesforce.browser.goto SoqlHandler.instance_url
|
152
|
+
```
|
153
|
+
|
154
|
+
Login through SOAP session to get information for browser
|
155
|
+
```ruby
|
156
|
+
user = LeapSalesforce::Users.where username: LeapSalesforce.ui_user
|
157
|
+
session = LeapSalesforce::Session.new user.username, LeapSalesforce.password,
|
158
|
+
user.security_token
|
159
|
+
```
|
135
160
|
|
136
161
|
## Development
|
137
162
|
|
data/Rakefile
CHANGED
data/install_chrome.sh
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
export CHROME_VERSION="google-chrome-stable"
|
3
|
+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
|
4
|
+
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
|
5
|
+
apt-get update -qqy
|
6
|
+
apt-get -qqy install google-chrome-stable
|
data/leap_salesforce_ui.gemspec
CHANGED
@@ -29,8 +29,8 @@ It reads the Metadata from Salesforce and creates the foundation for UI tests.'
|
|
29
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
|
-
spec.add_dependency "leap_salesforce", ">= 1.
|
33
|
-
spec.add_dependency "watir", "
|
32
|
+
spec.add_dependency "leap_salesforce", ">= 1.2.1"
|
33
|
+
spec.add_dependency "watir", "7"
|
34
34
|
spec.add_dependency "webdrivers"
|
35
35
|
|
36
36
|
# For more information and examples about making a new gem, checkout our
|
@@ -15,9 +15,11 @@ module BasePage
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# Visit the current page, logging in if required
|
18
|
-
|
18
|
+
# @param [Boolean] use_record_type Whether to specify record type
|
19
|
+
def visit(use_record_type: true)
|
19
20
|
LoginPage.login
|
20
21
|
page_url = "#{SoqlHandler.instance_url}/lightning/o/#{@soql_object.soql_object_name}/new"
|
22
|
+
page_url += '?useRecordTypeCheck=1' if use_record_type
|
21
23
|
LeapSalesforce.logger.info "Visiting #{self}"
|
22
24
|
browser.goto page_url
|
23
25
|
self
|
@@ -89,7 +89,7 @@ module LeapSalesforce
|
|
89
89
|
def set_picklist(label, value)
|
90
90
|
LeapSalesforce.logger.info "Setting picklist, label '#{label}' with '#{value}'"
|
91
91
|
field_transaction label, value do
|
92
|
-
dropdown = form.
|
92
|
+
dropdown = form.button(xpath: "//*[./*[text()='#{label}']]//following-sibling::div//button")
|
93
93
|
dropdown_id = dropdown.attribute "id"
|
94
94
|
LeapSalesforce.logger.debug "Using dropdown id: #{dropdown_id}"
|
95
95
|
dropdown.focus
|
@@ -41,8 +41,18 @@ Go to #{DISABLE_2STEP_URL} to learn how to disable it"
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def login
|
44
|
+
raise "Need to set LeapSalesforce.ui_user" unless LeapSalesforce.ui_user
|
44
45
|
LeapSalesforce.logger.info "Logging in as user '#{LeapSalesforce.ui_user}'"
|
45
|
-
|
46
|
+
if LeapSalesforce.login_through_session
|
47
|
+
browser.goto SoqlHandler.instance_url
|
48
|
+
user = LeapSalesforce::Users.where username: LeapSalesforce.ui_user
|
49
|
+
session = LeapSalesforce::Session.new user.username, LeapSalesforce.password, user.security_token
|
50
|
+
browser.cookies.add "sid", session.session_id
|
51
|
+
browser.cookies.add "sidClient", session.user_id
|
52
|
+
browser.goto SoqlHandler.instance_url
|
53
|
+
else
|
54
|
+
browser.goto "#{LeapSalesforce.general_url}/?un=#{LeapSalesforce.ui_user}&pw=#{LeapSalesforce.password}"
|
55
|
+
end
|
46
56
|
continue_button = browser.button(id: "thePage:inputForm:continue")
|
47
57
|
if continue_button.exists?
|
48
58
|
browser.checkbox(id: "thePage:inputForm:remember").set
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module LeapSalesforce
|
2
|
+
module SetRecordType
|
3
|
+
# Set record type for an object before create form appears
|
4
|
+
def set_record_type(record_type)
|
5
|
+
LeapSalesforce.logger.info "Setting record type to '#{record_type}'"
|
6
|
+
option = browser.label(xpath: "//label[.//*[@class='slds-form-element__label' and text()='#{record_type}']]")
|
7
|
+
option.click
|
8
|
+
browser.button(text: 'Next').click
|
9
|
+
self
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/leap_salesforce_ui.rb
CHANGED
@@ -35,6 +35,8 @@ module LeapSalesforce
|
|
35
35
|
@ui_user = nil
|
36
36
|
# @return [Boolean] Whether to run in headless mode
|
37
37
|
@headless = false
|
38
|
+
# @return [Boolean] Whether to login using session obtained via SOAP
|
39
|
+
@login_through_session = false
|
38
40
|
class << self
|
39
41
|
def browser(test_name = nil)
|
40
42
|
@browser ||= new_browser(test_name)
|
@@ -50,6 +52,8 @@ module LeapSalesforce
|
|
50
52
|
|
51
53
|
# @return [Boolean] Whether to run in headless mode. Default false
|
52
54
|
attr_accessor :headless
|
55
|
+
# @return [Boolean] Whether to login using session obtained via SOAP
|
56
|
+
attr_accessor :login_through_session
|
53
57
|
|
54
58
|
# @param [String, Symbol, Regexp, LeapSalesforce::User] user User or email address of user
|
55
59
|
def ui_user=(user)
|
@@ -66,7 +70,7 @@ module LeapSalesforce
|
|
66
70
|
def new_browser(test_name = nil)
|
67
71
|
if ENV["WEBDRIVER_URL"]
|
68
72
|
# TODO: Get working on Ruby 3
|
69
|
-
Watir::Browser.new :chrome, { **zalenium_args("LeapSalesforce", test_name || "Test") }
|
73
|
+
Watir::Browser.new :chrome, options: { **zalenium_args("LeapSalesforce", test_name || "Test") }
|
70
74
|
else
|
71
75
|
args = {}
|
72
76
|
args[:headless] = true if headless
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leap_salesforce_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IQA
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: leap_salesforce
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.
|
20
|
+
version: 1.2.1
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.
|
27
|
+
version: 1.2.1
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: watir
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: '7'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - '='
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: '7'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: webdrivers
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- config/general.rb
|
84
84
|
- docker-compose.yml
|
85
85
|
- exe/leap_salesforce_ui
|
86
|
+
- install_chrome.sh
|
86
87
|
- leap_salesforce_ui.gemspec
|
87
88
|
- lib/leap_salesforce_ui.rb
|
88
89
|
- lib/leap_salesforce_ui/base_page.rb
|
@@ -102,6 +103,7 @@ files:
|
|
102
103
|
- lib/leap_salesforce_ui/page_introspection.rb
|
103
104
|
- lib/leap_salesforce_ui/rake.rb
|
104
105
|
- lib/leap_salesforce_ui/rake/pom.rake
|
106
|
+
- lib/leap_salesforce_ui/set_record_type.rb
|
105
107
|
- lib/leap_salesforce_ui/update_page.rb
|
106
108
|
- lib/leap_salesforce_ui/version.rb
|
107
109
|
- lib/leap_salesforce_ui/view_page.rb
|