prestashop-automation 0.8.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 61473a9bed9006a46003629f1d6cb9fe4dfccba7
4
+ data.tar.gz: e887b0b1bd99f223a940170190c4eca7eb416ac2
5
+ SHA512:
6
+ metadata.gz: 3cf3de0e3ca2a76809e9749f1cff4eb70b28994a27333d5ad091f097eaba0dad8d9b7f3e8f9b0f744b3f43f1547b7a103f7a086471622eb46d6ae36a317725fb
7
+ data.tar.gz: 2914dedc175912fc4d4532cb6f8257c37a04eaabbaf5398a59ee6e155d8b8a1b52ea50954ccb4c2bbc865daab1d3f0df346a7356e50b07879a55d8502003fefe
File without changes
File without changes
File without changes
@@ -31,10 +31,12 @@ module PrestaShopAutomation
31
31
  fill_in 'infosPassword', :with => password
32
32
  fill_in 'infosPasswordRepeat', :with => password
33
33
 
34
- if options[:newsletter]
35
- check 'infosNotification'
36
- else
37
- uncheck 'infosNotification'
34
+ if has_selector? "#infosNotification"
35
+ if options[:newsletter]
36
+ check 'infosNotification'
37
+ else
38
+ uncheck 'infosNotification'
39
+ end
38
40
  end
39
41
 
40
42
  click '#btNext'
@@ -78,9 +80,17 @@ module PrestaShopAutomation
78
80
 
79
81
  def install_module name
80
82
  goto_admin_tab 'AdminModules'
81
- link = first("a[href*='install='][href*='controller=AdminModules']", :visible => false)['href']
82
- randomname = link[/\binstall=([^&?#]+)/, 1]
83
- link.gsub! randomname, name
83
+ if version_gte '1.6.0.7'
84
+ link = first("a[data-link*='&install='][data-link*='controller=AdminModules']", :visible => false)['data-link']
85
+ randomname = link[/\binstall=([^&?#]+)/, 1]
86
+ link.gsub! randomname, name
87
+ link = @back_office_url + link
88
+ puts link
89
+ else
90
+ link = first("a[href*='&install='][href*='controller=AdminModules']", :visible => false)['href']
91
+ randomname = link[/\binstall=([^&?#]+)/, 1]
92
+ link.gsub! randomname, name
93
+ end
84
94
  visit link
85
95
  #check that the entry was added to the DB
86
96
  expect(client.query("SELECT * FROM #{safe_database_name}.#{@database_prefix}module WHERE name='#{client.escape name}'").count).to be 1
File without changes
File without changes
File without changes
data/lib/actions/taxes.rb CHANGED
File without changes
@@ -0,0 +1,41 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+
4
+ module PrestaShopAutomation
5
+ module UsersActions
6
+ def create_user options={}
7
+
8
+ random_user = JSON.parse(RestClient.get('http://api.randomuser.me/'), :symbolize_names => true)[:results].first[:user]
9
+
10
+ visit @front_office_url
11
+ first('a.login').click
12
+ puts random_user
13
+ find('#email_create').set (options[:email] || random_user[:email])
14
+ click '#SubmitCreate'
15
+
16
+ click_label_for "id_gender#{(options[:gender] || random_user[:gender]) == 'female' ? 2 : 1}"
17
+
18
+ customer_firstname = options[:firstname] || random_user[:name][:first]
19
+ customer_lastname = options[:lastname] || random_user[:name][:last]
20
+ passwd = options[:password] || random_user[:password]
21
+
22
+ fill_in 'customer_firstname', :with => customer_firstname
23
+ fill_in 'customer_lastname', :with => customer_lastname
24
+ fill_in 'passwd', :with => passwd
25
+
26
+ click '#submitAccount'
27
+ first(:xpath, "//a[i/@class='icon-building']").click
28
+
29
+ select_random_option '#id_country'
30
+ select_random_option '#id_state'
31
+
32
+ if false
33
+ address1
34
+ city
35
+ phone_mobile
36
+ end
37
+
38
+ sleep 60
39
+ end
40
+ end
41
+ end
@@ -24,6 +24,18 @@ module PrestaShopAutomation
24
24
  end
25
25
  end
26
26
 
27
+ def get_select_options select_selector
28
+ all("#{select_selector} option", :visible => false).to_a.map do |option|
29
+ [option[:value], option.text]
30
+ end
31
+ end
32
+
33
+ def select_random_option select_selector
34
+ option = get_select_options(select_selector).sample[0]
35
+ puts "Option: #{option}"
36
+ select_by_value select_selector, option
37
+ end
38
+
27
39
  def select_by_value_jqChosen select_selector, value
28
40
  options = Hash[all("#{select_selector} option", :visible => false).to_a.each_with_index.map do |option, i|
29
41
  [option['value'], i]
@@ -77,5 +89,9 @@ module PrestaShopAutomation
77
89
  def get_cookies_string
78
90
  driver.browser.manage.all_cookies.map do |c| "#{c[:name]}=#{c[:value]}" end.join ";"
79
91
  end
92
+
93
+ def version_gte v
94
+ Gem::Version.new(@version.dup) >= Gem::Version.new(v.dup)
95
+ end
80
96
  end
81
97
  end
@@ -11,6 +11,7 @@ require_relative 'actions/carriers.rb'
11
11
  require_relative 'actions/cart_rules.rb'
12
12
  require_relative 'actions/orders.rb'
13
13
  require_relative 'actions/installer.rb'
14
+ require_relative 'actions/users.rb'
14
15
 
15
16
  require_relative 'helpers/general.rb'
16
17
 
@@ -40,6 +41,7 @@ module PrestaShopAutomation
40
41
  include PrestaShopAutomation::CartRulesActions
41
42
  include PrestaShopAutomation::OrdersActions
42
43
  include PrestaShopAutomation::InstallerActions
44
+ include PrestaShopAutomation::UsersActions
43
45
 
44
46
  # Rspec defines this method, but we want the one from Capybara::Session
45
47
  def all *args
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prestashop-automation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
5
- prerelease:
4
+ version: 0.9.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - François-Marie de Jouvencel
@@ -14,109 +13,100 @@ dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: mysql2
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: selenium-webdriver
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: capybara
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
- description: ! 'A nice ruby framework to build complex selenium tests around PrestaShop.
79
-
80
- This gem provides building blocks to create advanced scenarios in a very consise
81
- way.'
69
+ description: |-
70
+ A nice ruby framework to build complex selenium tests around PrestaShop.
71
+ This gem provides building blocks to create advanced scenarios in a very consise way.
82
72
  email: fm.de.jouvencel@gmail.com
83
73
  executables: []
84
74
  extensions: []
85
75
  extra_rdoc_files: []
86
76
  files:
87
- - lib/prestashop-automation.rb
88
- - lib/helpers/general.rb
89
- - lib/actions/products.rb
90
- - lib/actions/installer.rb
91
- - lib/actions/cart_rules.rb
92
77
  - lib/actions/carriers.rb
78
+ - lib/actions/cart_rules.rb
79
+ - lib/actions/general.rb
80
+ - lib/actions/installer.rb
93
81
  - lib/actions/orders.rb
82
+ - lib/actions/products.rb
94
83
  - lib/actions/settings.rb
95
- - lib/actions/general.rb
96
84
  - lib/actions/taxes.rb
85
+ - lib/actions/users.rb
86
+ - lib/helpers/general.rb
87
+ - lib/prestashop-automation.rb
97
88
  homepage: https://github.com/djfm/prestashop-automation
98
89
  licenses:
99
90
  - OSL
91
+ metadata: {}
100
92
  post_install_message:
101
93
  rdoc_options: []
102
94
  require_paths:
103
95
  - lib
104
96
  required_ruby_version: !ruby/object:Gem::Requirement
105
- none: false
106
97
  requirements:
107
- - - ! '>='
98
+ - - ">="
108
99
  - !ruby/object:Gem::Version
109
100
  version: '0'
110
101
  required_rubygems_version: !ruby/object:Gem::Requirement
111
- none: false
112
102
  requirements:
113
- - - ! '>='
103
+ - - ">="
114
104
  - !ruby/object:Gem::Version
115
105
  version: '0'
116
106
  requirements: []
117
107
  rubyforge_project:
118
- rubygems_version: 1.8.23
108
+ rubygems_version: 2.2.2
119
109
  signing_key:
120
- specification_version: 3
110
+ specification_version: 4
121
111
  summary: Framework to test and automate tasks in PrestaShop.
122
112
  test_files: []