本文整理汇总了Python中splinter.Browser.is_element_not_present_by_tag方法的典型用法代码示例。如果您正苦于以下问题:Python Browser.is_element_not_present_by_tag方法的具体用法?Python Browser.is_element_not_present_by_tag怎么用?Python Browser.is_element_not_present_by_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类splinter.Browser
的用法示例。
在下文中一共展示了Browser.is_element_not_present_by_tag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import is_element_not_present_by_tag [as 别名]
def main():
#how many accounts we need
ntimes = 1
for i in range(1,ntimes+1):
print "starting browser"
firstname = names.get_first_name()
#print "firstname", firstname
lastname = names.get_last_name()
#print "lastname", lastname
browser = Browser() #Browser(user_agent="Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)")
browser.visit('https://passport.yandex.com/registration/mail')
browser.find_by_id('firstname').fill(firstname)
browser.find_by_id('lastname').fill(lastname)
testlogin = False
count = 0
while (testlogin == False):
count = count + 1
login = firstname+lastname+str(randint(10,1000))
print "login:", login
browser.find_by_id('login').fill(login)
browser.is_element_not_present_by_css("div.control__error__login_notavailable", wait_time=2)
if browser.is_text_present("username available"):
testlogin = True
else:
print "login is not available, generate new"
if (count>3):
#print "logins in this script is unavailable now, please make new login generator"
browser.quit()
sys.exit("logins in this script is unavailable now, please make new login generator")
password = password_generator.generate()
print "password:", password
browser.find_by_id('password').fill(password)
browser.find_by_id('password_confirm').fill(password)
#click on select
browser.find_by_name("hint_question_id").click()
#wait
browser.is_element_not_present_by_css("li[role=\"presentation\"]", wait_time=3)
#check first question
browser.find_by_css("li[role=\"presentation\"]")[1].click()
browser.find_by_id("hint_answer").fill(firstname)
gateimgcode = captcha(browser)
browser.find_by_id('answer').fill(gateimgcode)
browser.find_by_css("button[type=\"submit\"]").click()
testcaptcha = False
count = 0
while (testcaptcha == False):
count = count + 1
browser.is_element_not_present_by_css("div.control__error__captcha_incorrect", wait_time=2)
if browser.is_text_present("characters were entered incorrectly"):
print "captcha code is bad, try again"
browser.find_by_id('password').fill(password)
browser.find_by_id('password_confirm').fill(password)
gateimgcode = captcha(browser)
browser.find_by_id('answer').fill(gateimgcode)
browser.find_by_css("button[type=\"submit\"]").click()
else:
testcaptcha = True
if (count>3):
#print "something wrong with captcha"
browser.quit()
sys.exit("something wrong with captcha")
browser.is_element_not_present_by_tag("html", wait_time=2)
if browser.is_text_present("Personal information"):
today = datetime.date.today()
filename = 'yandex'+str(today)+'.txt'
file = open(filename,'a')
file.write(login+'@yandex.com'+':'+login+':'+password+'\n')
file.close()
print str(i)+" accounts saved to "+filename
browser.quit()
else:
#print "something wrong, please start script again"
browser.quit()
sys.exit("something wrong, please start script again")