Repository navigation
Expand file tree
/
Copy pathOnePlusTwo.py
More file actions
100 lines (82 loc) · 3 KB
/
Copy pathOnePlusTwo.py
File metadata and controls
100 lines (82 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
__author__ = 'shashir'
from splinter import Browser
import time
import logging
#This function opens the one plus site in one browser and temporary email generating site in another browser.
def ConnectionSetup():
global browser
browser = Browser()
global browser1
browser1= Browser()
browser.visit("https://oneplus.net/invites?kolid=FDO5LS")
print '--opened one plus site'
browser1.visit("http://temp-mail.org/")
print '--opened fake email generation site'
#This function takes the email id generated by FakeMail() function registers with that id.
def OnePlus():
if browser.is_element_present_by_id('email', wait_time=15):
browser.find_by_id('email').click()
print '--found email text box'
browser.fill('invite-email', email)
print '--entered email id'
if browser.is_element_present_by_id('submit_email', wait_time=15):
browser.find_by_id('submit_email').click()
print '--clicked on Submit button'
#This function generates a new temporary email id on the given site.
def FakeMail():
if browser1.is_element_present_by_id("click-to-delete", wait_time=30):
browser1.find_by_id("click-to-delete").click()
print '--clicked on Delete button'
time.sleep(5)
global email
emailid = browser1.find_by_xpath(".//*[@id='mail']").first
email = str(emailid.value)
print email
print '--copied email id'
#This function checks the email for confirm signup button and clicks on that button for registration confirmation.
def ConfirmSign():
try:
if browser1.is_element_present_by_xpath(".//*[@id='mails']/tbody/tr/td[2]/a", wait_time=30):
print '--checked for email received '
time.sleep(8)
browser1.find_by_xpath(".//*[@id='mails']/tbody/tr/td[2]/a").click()
print '--clicked on received email'
time.sleep(3)
browser1.find_by_xpath("html/body/div[1]/div/div/div[2]/div[1]/div/div[3]/div[1]/div/div/p/a").click()
print '--clicked on confirm signup button'
except Exception, e:
logging.log('','')
print e
pass
#This function checks whether the process is successful or not.
def SuccessOrFailure():
if browser.is_element_present_by_id('totalInvited', wait_time=15):
print '--successful run:' + str(j)
browser.reload()
print '--reloaded one plus website'
browser1.back()
print '--backwarded fake mail website'
else:
print '--failed run:' + str(j)
#This function calls the above defined function in the partucular sequece in infine loop so that the registration process keeps on running.
def MasterFunction():
ConnectionSetup()
global i
i = 1
global j
j = 1
while i != 0:
FakeMail()
OnePlus()
ConfirmSign()
SuccessOrFailure()
j += 1
try:
MasterFunction()
except:
logging.log('','')
pass
finally:
browser.quit()
browser1.quit()
MasterFunction()