Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #1 - Changes to order of forms in Shopify's activate account page have broken mechanize_activate_customer_login.rb #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions mechanize_activate_customer_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,31 @@
puts "Using activation code as customer password"

pp activate_result_page

activate_form = activate_result_page.forms.first
# if you're generating a random password, you could use the invite code

# Loops through all forms on activate_result_page to identify form which contains password fields,
# and assigns discovered field to activate_form
activate_form = nil
activate_result_page.forms.each do |form|
form.fields.each do |field|
if field.name.include?('password')
activate_form = form
break
end
end
end

# if you're generating a random password, you could use the invite code
# because it is randomly generated each time the invite email is displayed
activate_form['customer[password]'] = customer_password
activate_form['customer[password_confirmation]'] = customer_password

puts "Submitting activation form"

pp agent.submit(activate_form, activate_form.buttons.first)

last_time, this_time = this_time, Time.now
puts " ... elapsed total (#{this_time-start_time}) since last (#{this_time-last_time})"

puts "Email (#{customer_email})"

end
end