本文整理汇总了Python中twill.commands.submit函数的典型用法代码示例。如果您正苦于以下问题:Python submit函数的具体用法?Python submit怎么用?Python submit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了submit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
def login():
if s218:
page = 'http://129.21.142.218:8008/securesync/login/'
username = 'JSteacher'
password = 'poipoi99'
facility = '0939bcf9d5fe59ff8fde46b5a729a232'
else:
page = 'http://129.21.142.118:8008/securesync/login/'
username = 'knowledgecraft'
password = 'knowledgecraft'
facility = 'dbae7005f9b45ce082b5fe0a0985946a'
print 'Logging In...'
go(page)
print "Forms:"
showforms()
try:
# Force try using the first form found on a page.
formclear('2')
fv("2", "username", username)
fv("2", "password", password)
fv("2", "facility", facility)
#fv("1", "csrfmiddlewaretoken", '3F1bMuIIM9ERzcp6ceEyFxlT51yJKsK6')
submit('0')
content = showSilently()
print 'debug twill post content:', content
except urllib2.HTTPError, e:
sys.exit("%d: %s" % (e.code, e.msg))
示例2: upload
def upload(self, input):
self.get("/tool_runner/index?tool_id=upload1")
tc.fv("1", "file_type", "bed")
tc.fv("1", "dbkey", input.get('dbkey', '?'))
tc.formfile("1", "file_data", input['file_path'])
tc.submit("runtool_btn")
tc.code(200)
示例3: send
def send(self, msg, *send_to):
"""
@todo: make use of native vodafone multi-recipients functionality
"""
for contact in send_to:
web.follow(self.SERVICE_URL)
try:
web.find("/myv/messaging/webtext/Challenge.shtml")
except twill.errors.TwillAssertionError, e:
pass
else:
web.go("/myv/messaging/webtext/Challenge.shtml")
with tempfile.NamedTemporaryFile(suffix=".jpeg") as captcha:
web.save_html(captcha.name)
web.back()
os.system("open %s " % captcha.name)
web.formvalue("WebText", "jcaptcha_response", raw_input("Captcha: "))
web.formvalue("WebText", "message", msg)
to = getattr(contact, "mobile", contact)
web.formvalue("WebText", "recipient_0", to)
web.sleep(2)
web.submit()
web.code(200)
web.find("Message sent!")
示例4: main
def main():
login, password = get_credentials()
# log-in to Django site
if login and password:
tw.go(LOGIN_URL)
tw.formvalue('1', 'username', login)
tw.formvalue('1', 'password', password)
tw.submit()
if isinstance(DATA_URL, basestring):
urls = [DATA_URL]
else:
urls = list(DATA_URL)
# retrieve URIs
for url in urls:
try:
tw.go(url)
tw.code('200')
tw.show()
except TwillAssertionError:
code = get_browser().get_code()
print (u"Unable to access %(url)s. "
u"Received HTTP #%(code)s."
% {'url': url, 'code': code})
tw.reset_browser()
示例5: refresh_form
def refresh_form(self, control_name, value, form_no=0, form_id=None, form_name=None, **kwd):
"""Handles Galaxy's refresh_on_change for forms without ultimately submitting the form"""
# control_name is the name of the form field that requires refresh_on_change, and value is
# the value to which that field is being set.
for i, f in enumerate(self.showforms()):
if i == form_no or (form_id is not None and f.id == form_id) or (form_name is not None and f.name == form_name):
break
formcontrols = self.get_form_controls(f)
try:
control = f.find_control(name=control_name)
except Exception:
log.debug('\n'.join(formcontrols))
# This assumes we always want the first control of the given name, which may not be ideal...
control = f.find_control(name=control_name, nr=0)
# Check for refresh_on_change attribute, submit a change if required
if 'refresh_on_change' in control.attrs.keys():
# Clear Control and set to proper value
control.clear()
tc.fv(f.name, control.name, value)
# Create a new submit control, allows form to refresh, instead of going to next page
control = ClientForm.SubmitControl('SubmitControl', '___refresh_grouping___', {'name': 'refresh_grouping'})
control.add_to_form(f)
control.fixup()
# Submit for refresh
tc.submit('___refresh_grouping___')
示例6: setup
def setup(
self,
login=None,
password=None,
service_url="https://bramka.play.pl",
login_url="https://logowanie.play.pl/p4-idp2/LoginForm.do",
logout_url="https://logowanie.play.pl/p4-idp2/LogoutUser",
):
self.SERVICE_URL = service_url
self.LOGIN_URL = login_url
self.LOGOUT_URL = logout_url
self.MY_PHONE_NUMBER = login
self.MY_PASSWORD = password
web.config("readonly_controls_writeable", True)
web.agent(self.MY_HTTP_AGENT)
web.go(self.SERVICE_URL)
web.submit()
web.code(200)
web.formvalue("loginForm", "login", self.MY_PHONE_NUMBER)
web.formvalue("loginForm", "password", self.MY_PASSWORD)
web.submit()
web.code(200)
self._retry_find("editableSmsComposeForm", 5)
示例7: make_intranets
def make_intranets(intranets_name):
""" Make the offices root hierarchy, deleting if it exists"""
global_dict, local_dict = namespaces.get_twill_glocals()
global_dict['intranets_name'] = intranets_name
# Check to see if we have that community, if so, delete it.
commands.go('/' + intranets_name)
br = get_browser()
status = br.get_code()
if status != 404:
# The community shouldn't exist, and so we should get 404
# looking for it. If no 404, then it exists and we should
# delete it.
url = "/%s/delete.html?confirm=1" % intranets_name
commands.go(url)
# Now, make the community and make sure it exists
commands.go("/add_community.html")
commands.fv("save", "title", intranets_name)
desc = "Test intranets root created for Twill test case named '%s'"
commands.fv("save", "description", desc % test_name)
commands.submit()
commands.find("Add Existing")
示例8: create
def create(self, cntrller='user', email='[email protected]', password='testuser', username='admin-user', redirect=''):
# HACK: don't use panels because late_javascripts() messes up the twill browser and it
# can't find form fields (and hence user can't be logged in).
params = dict(cntrller=cntrller, use_panels=False)
self.visit_url("/user/create", params)
tc.fv('registration', 'email', email)
tc.fv('registration', 'redirect', redirect)
tc.fv('registration', 'password', password)
tc.fv('registration', 'confirm', password)
tc.fv('registration', 'username', username)
tc.submit('create_user_button')
previously_created = False
username_taken = False
invalid_username = False
try:
self.check_page_for_string("Created new user account")
except Exception:
try:
# May have created the account in a previous test run...
self.check_page_for_string("User with that email already exists")
previously_created = True
except Exception:
try:
self.check_page_for_string('Public name is taken; please choose another')
username_taken = True
except Exception:
try:
# Note that we're only checking if the usr name is >< 4 chars here...
self.check_page_for_string('Public name must be at least 4 characters in length')
invalid_username = True
except Exception:
pass
return previously_created, username_taken, invalid_username
示例9: find_price
def find_price(name, vintage, volume):
formlist = []
#com.showforms()
all_forms = cbrw.get_all_forms()
for each_form in all_forms:
formlist.append(each_form.name)
if 'searchform' in formlist:
com.formclear("searchform")
com.fv("searchform", "Xwinename", name)
com.fv("searchform", "Xvintage", vintage)
com.fv("searchform", "Xstateid", "CA")
com.fv("searchform", "Xbottle_size", "Bottles")
#com.fv("searchform", "Xprice_set", "CUR")
com.submit()
url = com.browser.get_url()
#print url
page=urllib2.urlopen(url)
soup = BeautifulSoup(page.read())
prices=soup.findAll('span',{'class':'offer_price boldtxt'})
price_values = []
for price in prices:
#print float((price.next).replace(",", ""))
price_values.append(float((price.next).replace(",", "")))
if len(price_values) > 0:
return min(price_values), max(price_values), np.mean(price_values)
else:
return 'unknown', 'unknown', 'unknown'
else:
return 'unknown', 'unknown', 'unknown'
示例10: login
def login(username):
"""Find user for given username and make the browser logged in"""
global_dict, local_dict = namespaces.get_twill_glocals()
# Set a globabl Twill variable to let Twill scripts now the name
# of the test, e.g. the directory, as well as community name.
#global_dict['test_name'] = test_name
#global_dict['community_name'] = test_name + "-testcase"
global_dict['cwd'] = os.getcwd()
hn = global_dict['localhost_url']
# First logout
logout()
# Do a login
au = global_dict['%s_user' % username]
# Echo to screen
dump("Logging into %s as %s" % (hn, au))
# Continue
ap = global_dict['%s_password' % username]
commands.go(hn + '/login.html')
commands.fv("formLogin", "login", au)
commands.fv("formLogin", "password", ap)
commands.submit()
# Make sure the login succeeded
commands.show()
commands.find("My Profile")
示例11: test_project_manager_sharing
def test_project_manager_sharing(self):
# test sharing as a manager
# main page
tc.go( testlib.PROJECT_LIST_URL )
tc.find("Logged in as")
# default project list
tc.find("Yeast mutant RAV 17")
tc.follow("Yeast mutant RAV 17")
tc.follow("Sharing")
tc.find("Current members")
tc.find("Add access")
# search for then add Demo User to this project
tc.fv("1", "text", "demo" )
tc.submit()
tc.code(200)
tc.find("Demo User")
tc.follow("add as member")
tc.find("Demo User")
# back to the project view
tc.follow("<< return to project")
tc.find("Yeast mutant RAV 17")
示例12: login
def login(username, password):
t.add_extra_header("User-Agent", "[email protected]")
t.go(host + "index.php/Special:UserLogin")
t.fv("1", "wpName", username)
t.fv("1", "wpPassword", password)
t.submit("wpLoginAttempt")
示例13: test_project_actions
def test_project_actions(self):
# main page
tc.go( testlib.PROJECT_LIST_URL )
tc.find("Logged in as")
# default project list
tc.find("Fly data 19")
tc.find("Human HELA 16")
tc.find("Mouse project HBB 1")
# create a new project
name = "Rainbow Connection - New Project"
self.create_project(name=name)
# visit this new project
tc.follow(name)
tc.code(200)
tc.find("Project: %s" % name)
# edit and rename project
newname = "Iguana Garden - New Project"
tc.follow("Edit")
tc.find("Edit Project")
tc.fv("1", "name", newname )
tc.fv("1", "info", "Some other *markup* goes here")
tc.submit()
tc.code(200)
tc.notfind(name)
tc.find(newname)
self.delete_project(name=newname)
示例14: __init__
def __init__ (self, email, password):
Browser.go(PANDORA_LOGIN_URL)
Browser.formvalue(1, 'login_username', email)
Browser.formvalue(1, 'login_password', password)
Browser.submit()
self.webname = Browser.info().split('/').pop()
示例15: test_confirm_password_reset
def test_confirm_password_reset(self):
"""
create confirmation link as Django engine and
test it for resetting password
"""
test_email = '[email protected]'
go(SITE)
code(200)
follow('reset password')
code(200)
fv(2, 'email', test_email)
submit()
code(200)
#create links
from django.contrib.auth.tokens import default_token_generator
from django.utils.http import int_to_base36
users = User.objects.filter(email__iexact=test_email)
for user in users:
link = "%s/accounts/password/reset_confirm/%s/%s/" % (SITE,
int_to_base36(user.id),
default_token_generator.make_token(user))
go(link)
code(200)
find('Password reset confirm')
fv(2, 'new_password1', 'test')
fv(2, 'new_password2', 'test')
submit()
code(200)
find('Your password was successfully reseted')
self.general_login_action(user.username,
'test',
"Welcome, %s" % user.username)