Last Updated: February 25, 2016
·
401
· blazeeboy

Submit Protip to Coderwall.com using Selenium

each day i hae to sumit to several social networks including Facebook, twitter, google+, linkedin, coderwall, and several other websites.

this is alot of time spent on the same steps over and over, some websites doesn't have API to submit like Coderwall for example, so i have to simulate my behaviour using selenium.

this script uses github to login to coderwall.com and submit a new protip, script has two parts, first goes to the coderwall github authentication link, login using user data, it forward back to coderwall, second it goes to the new protip link and submit the data.

it uses firefox web driver, so firefoz should be installed on your system.

Gist : https://gist.github.com/9853977

#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
require "selenium-webdriver" # gem install selenium-webdriver
require "highline/import" # gem install highline

def coderwall github_email, github_password, title, content, tags

driver = Selenium::WebDriver.for :firefox

driver.navigate.to "https://coderwall.com/auth/github"

driver.find_element(:css, '#login_field').send_keys github_email
passwordf = driver.find_element(:css, '#password')
passwordf.send_keys github_password
passwordf.submit

driver.navigate.to "https://coderwall.com/p/new"
driver.find_element(:css, '#protip_title').send_keys title
driver.find_element(:css, '#protip_body').send_keys content
driver.find_element(:css, '#protip_tags').send_keys tags
driver.find_element(:css, '.new_protip').submit

driver.quit
end

email = ask 'What is your github email address ? '
password = ask('And github password? '){ |q| q.echo = '*' }
coderwall email, password, 'Title here', 'Content here', 'ruby, test'