How to use watir-webdriver
#!/usr/bin/ruby
require 'rubygems'
require 'watir-webdriver'
o = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten
string = (0...8).map{ o[rand(o.length)] }.join
# settings
username = "michael@moorberry.net"
password = "password"
imagepath = "/assets/locations/github.gif"
# create new instance
browser = Watir::Browser.new
browser.goto "https://twitter.com/"
# login
browser.text_field(:id => "signin-email").set username
browser.text_field(:id => "signin-password").set password
browser.button(:class => "js-submit").click
# change profile settings
browser.goto "https://twitter.com/settings/password"
# sleep(2)
browser.text_field(:id => 'current_password').set password
browser.text_field(:id => 'user_password').set string
browser.text_field(:id => 'user_password_confirmation').set string
browser.button(:id => "settings_save").click
# sleep(2)
puts browser.text.include? 'Your password has been changed'
puts string
#!/usr/bin/ruby
require 'rubygems'
require 'watir-webdriver'
# settings
username = "USERNAME"
password = "PASSWORD"
imagepath = "/Users/alex/image.png"
# create new instance
browser = Watir::Browser.new
browser.goto "https://twitter.com/"
# login
browser.text_field(:id => "signin-email").set username
browser.text_field(:id => "signin-password").set password
browser.button(:class => "js-submit").click
# change profile settings
browser.goto "https://twitter.com/settings/profile"
sleep(1)
browser.button(:id => "profile_image_upload").click
browser.file_field(:class => "file-input").send_keys(imagepath)
sleep(2)
browser.link(:text => "Save").click
require 'watir-webdriver'
# update with your credentials
username = "username"
password = "pass"
photo = "/path/to/photo.jpeg"
b = Watir::Browser.new :chrome
b.goto 'twitter.com'
b.text_field(:id => 'signin-email').set username
b.text_field(:id => 'signin-password').set password
b.button(:class => 'submit btn primary-btn flex-table-btn js-submit').click
b.goto 'twitter.com/settings/profile'
sleep(5)
b.button(:id => 'profile_image_upload').click
b.file_field(:name, "media[]").set photo
l = b.link :text => 'Save'
l.exists?
l.click