How to use see_form method in lettuce_webdriver

Best Python code snippet using lettuce_webdriver_python

views.py

Source:views.py Github

copy

Full Screen

1from django.contrib.auth import authenticate, login2from django.views import View3from django.shortcuts import render, redirect4from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm5from django.contrib.auth.views import LoginView, LogoutView6from .form import *7from .db_connection import *8from django.contrib.auth.decorators import login_required9from .models import User10from django.views.generic import TemplateView11from django.contrib.auth.mixins import LoginRequiredMixin12from django.contrib.auth import update_session_auth_hash13from django.core.cache import cache14from .test_payment import *15class Register(View):16 template_name = 'registration/register.html'17 def get(self, request):18 context = {19 'form': UserCreation()20 }21 return render(request, self.template_name, context)22 def post(self, request):23 form = UserCreation(request.POST)24 if form.is_valid():25 form.save()26 phone_number = form.cleaned_data.get('phone_number')27 password = form.cleaned_data.get('password')28 user = form.save()29 login(request, user)30 return redirect('home')31 else:32 print(form.errors)33 print(form.error_messages)34 context = {35 'form': form36 }37 return render(request, self.template_name, context)38class Login(View):39 template_name = 'registration/login.html'40 def get(self, request):41 context = {42 'form': UserAuthorisation()43 }44 return render(request, self.template_name, context)45 def post(self, request):46 form = UserAuthorisation(request.POST)47 if form.is_valid():48 phone_number = form.cleaned_data.get('phone_number')49 password = form.cleaned_data.get('password')50 user = authenticate(request, phone_number=phone_number, password=password)51 login(request, user)52 return redirect('home')53 else:54 print(form.errors)55 print(form.error_messages)56 context = {57 'form': form58 }59 return render(request, self.template_name, context)60def password_change(request):61 if request.method == 'POST':62 change_form = PasswordChangeForm(request.user, request.POST)63 if change_form.is_valid():64 user = change_form.save()65 update_session_auth_hash(request, user)66 data = {"change_form": change_form}67 else:68 change_form = PasswordChangeForm(request.user)69 data = {"change_form": change_form}70 return render(request, 'registration/password_change.html', context=data)71def index(request):72 return render(request, 'usersdata/registration.html')73@login_required74def profile(request):75 #course_data = Course.objects.filter(phone_number_id=request.user.pk)76 #for course in course_data:77 # print(course.name)78 try:79 # category_names = choose_category()80 category_names = ['Выберите категорию', '']81 except:82 category_names = ['Выберите категорию', '']83 data = {"category_names": category_names}84 return render(request, 'registration/profile.html', context=data)85@login_required86def profile_change(request):87 try:88 # category_names = choose_category()89 category_names = ['Выберите категорию', '']90 except:91 category_names = ['Выберите категорию', '']92 if request.method == 'POST':93 profile_form = UpdateProfileForm(request.POST, instance=request.user)94 if profile_form.is_valid():95 profile_form.save()96 return redirect(to='/users/profile')97 else:98 profile_form = UpdateProfileForm(instance=request.user)99 data = {"category_names": category_names, 'profile_form': profile_form}100 return render(request, 'registration/profile_change.html', context=data)101@login_required102def payment(request):103 course_id = request.GET['course_id']104 course_url = request.GET['course_url']105 cost = course_cost(course_id)106 dates = course_dates('"' + course_url + '"')107 jsOperationId = ''108 see_form = False109 if request.method == 'POST':110 profile_form = UpdateProfileForm(request.POST, instance=request.user)111 if profile_form.is_valid():112 profile_form.save()113 order_id = 'i' + str(request.user.pk) + 'c' + str(course_id)114 phone_number = request.user.phone_number115 email = request.user.email116 name = request.user.username117 date = request.POST.get('date')118 print(date)119 pay = test_payment(cost, phone_number, email, name, date, order_id)120 print(pay)121 re = pay.json()122 pay_url = re["userWebLink"]123 jsOperationId = re["jsOperationId"]124 see_form = True125 data = {"cost": cost, 'dates': dates, 'profile_form': profile_form, 'jsOperationId': str(jsOperationId), 'see_form': see_form}126 print(pay_url)127 # return redirect(to=pay_url)128 return render(request, 'payment/payment_page.html', context=data)129 else:130 profile_form = UpdateProfileForm(instance=request.user)131 data = {"cost": cost, 'dates': dates, 'profile_form': profile_form, 'jsOperationId': jsOperationId, 'see_form': see_form}132 return render(request, 'payment/payment_page.html', context=data)133def popytka(request):...

Full Screen

Full Screen

login.py

Source:login.py Github

copy

Full Screen

...11 print 'URL = ', url12 response = world.browser.get(url)13 world.dom = html.fromstring(response.content)14@step(r'I see an input for username')15def see_form(step):16 text_input = world.dom.cssselect('#id_username')17 assert len(text_input) == 118 19@step(r'I dont fill the password input')20def empty_password_input(step):21 pass22 23@step(r'I submit the form')24def submit_form(step):25 url = django_url('login/')26 response = world.browser.post(url, {'username': 'abc', 'password': ''})27 world.dom = html.fromstring(response.content)28 29@step(r'I get password empty error message')...

Full Screen

Full Screen

samepage.py

Source:samepage.py Github

copy

Full Screen

...3@app.route('/')4def main_page():5 return "Here's the main page. <a href='http://localhost:5000/seeform'>Click here to see the form</a>."6@app.route('/seeform',methods=["GET","POST"])7def see_form():8 formstring = """<br><br>9 <form action="" method='POST'>10 Enter a phrase: <br>11<input type="text" name="phrase"> 12<input type="submit" value="Submit">13""" ## HINT: In there ^ is where you need to add a little bit to the code...14 if request.method == "POST":15 rq=request.form['phrase']16 return formstring+'<br>'+rq17 else:18 return formstring19if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lettuce_webdriver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful