SHARE
TWEET

Untitled

a guest Nov 14th, 2017 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import selenium
  2. from selenium import webdriver
  3. from selenium.webdriver.common.keys import Keys
  4. from selenium.webdriver.common.by import By
  5. from selenium.webdriver.support.ui import WebDriverWait
  6. from selenium.webdriver.support import expected_conditions as EC
  7. import random
  8. from time import sleep
  9. def runner():
  10.     namesList = [
  11.         "KaylaH",
  12.         "Kimberlee",
  13.         "kassxox"
  14.     ]
  15.     #should be 2, changed to 0 for testing
  16.     randNumber = random.randint(0, 0)
  17.     print(randNumber)
  18.  
  19.     driver = webdriver.Chrome(executable_path=r'C:\Users\Will Turner\Desktop\selen\chromedriver.exe')
  20.  
  21.     driver.get('http://www.teenchat.com')
  22.     str1 = driver.title
  23.     print(str1)
  24.  
  25.     name_selector = driver.find_element_by_css_selector('#login > label > div.input.username > input')
  26.     name_selector.send_keys(namesList[randNumber])
  27.     sleep(2)
  28.  
  29.     age_selector = driver.find_element_by_css_selector('#login > label > div.age > a.action.age18')
  30.     age_selector.click()
  31.     sleep(2)
  32.  
  33.     gender_selector = driver.find_element_by_css_selector('#login > label > div.gender > a.action.male')
  34.     gender_selector.click()
  35.     sleep(2)
  36.  
  37.     join_room = driver.find_element_by_css_selector('#login > label > a > span')
  38.     join_room.click()
  39.     sleep(2)
  40.  
  41.     # get the window handles using window_handles
  42.     window_after = driver.window_handles[1]
  43.     print(window_after.title())
  44.     driver.switch_to.window(window_after)
  45.     print('**** sleeping for 35 seconds so teenchat can check the connection****')
  46.     sleep(35)
  47.     print('**** finished sleeping for 35 seconds ****')
  48.     chat = driver.find_element_by_css_selector('#publicChat > div.chatrooms > div > div.input > textarea')
  49.  
  50.     sleep(4)
  51.     #Kayla
  52.     if randNumber == 0:
  53.         firstMessageGen = rand.randInt(0, 1)
  54.         if firstMessageGen == 0:
  55.             chat.send_keys('hey' + Keys.ENTER)
  56.         if firstMessageGen == 1:
  57.             chat.send_keys('heyy' + Keys.ENTER)
  58.  
  59.         sleep(3)
  60.         #begin second message shit
  61.         secondMessageGen = rand.randInt(0, 2)
  62.         if secondMessageGen == 0:
  63.             #this would be so much easier if i weren't too lazy to learn spintax lol
  64.             chat.send_keys('add me on snap @ kaylah9999' + Keys.ENTER)
  65.             sleep(30)
  66.             #browser.quit()
  67.             sleep(360)
  68.             runner()
  69.             print('fin')
  70.         if secondMessageGen == 1:
  71.             chat.send_keys('hmu on the snap kaylah9999' + Keys.ENTER)
  72.             sleep(30)
  73.             #browser.quit()
  74.             sleep(360)
  75.             print('fin')
  76.             runner()
  77.         if secondMessageGen == 2:
  78.             chat.send_keys('add me on snapchat kaylah9999' + Keys.ENTER)
  79.             sleep(30)
  80.            # browser.quit()
  81.             print('fin')
  82.             sleep(360)
  83.             runner()
  84.     #Kimberlee
  85.     if randNumber == 1:
  86.         chat.send_keys('my name is Kimberlee' + Keys.ENTER)
  87.         print("name is kimberlee")
  88.     if randNumber == 2:
  89.         chat.send_keys('my name is kass' + Keys.ENTER)
  90.         print   ("name is kass")
RAW Paste Data
Pastebin PRO BLACK FRIDAY Special!
Get 60% OFF on Pastebin PRO accounts!
Top