from selenium import webdriver import time import string import random from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException baseurl = "http://www.quirky.com/signup" for x in range(0,10): lst = [random.choice(string.ascii_letters) for n in xrange(7)] lastname = "".join(lst) lst = [random.choice(string.ascii_letters) for n in xrange(5)] firstname = "".join(lst) lst = [random.choice(string.ascii_letters) for n in xrange(10)] password = "".join(lst) lst = [random.choice(string.ascii_letters) for n in xrange(8)] email1 = "".join(lst) lst = [random.choice(string.ascii_letters) for n in xrange(5)] email2 = "".join(lst) emailid = email1+'@yahoo.co.in' xpaths = { 'firstnameTxtBox' : "//input[@name='user[profile_attributes][first]']", 'lastnameTxtBox' : "//input[@name='user[profile_attributes][last]']", 'emailidTxtBox' : "//input[@name='user[email]']", 'passwordTxtBox' : "//input[@name='user[password]']", 'submitButton' : "//button[contains(text(),'Sign up')]" } mydriver = webdriver.Firefox() mydriver.get(baseurl) time.sleep(5) mydriver.find_elements_by_xpath(xpaths['firstnameTxtBox'])[1].send_keys(firstname) mydriver.find_elements_by_xpath(xpaths['lastnameTxtBox'])[1].send_keys(lastname) mydriver.find_elements_by_xpath(xpaths['emailidTxtBox'])[1].send_keys(emailid) mydriver.find_elements_by_xpath(xpaths['passwordTxtBox'])[1].send_keys(password) mydriver.find_element_by_xpath(xpaths['submitButton']).click() time.sleep(15) nexturl = "http://www.quirky.com/invent/827438/action/vote/query/sort=ending_soon&categories=all" mydriver.get(nexturl) xpaths_new = { 'vote_button' : "//div[contains(@tid, 'ideation-card-vote-button')]" } voting_button = mydriver.find_element_by_xpath(xpaths_new['vote_button']) if voting_button: voting_button.click() mydriver.quit() time.sleep(8)