Notes
![]() ![]() Notes - notes.io |
from django.contrib.auth.models import User
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
class BaseAuthentication(StaticLiveServerTestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName='runTest')
#dane konta testowego
self.username = "test"
self.email = "[email protected]"
self.password = "DoZmiany123!"
@classmethod
def setUpClass(cls):
#otwieramy przeglądarkę
super().setUpClass()
# firefox
"""
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_argument('--headless')
cls.selenium = WebDriver(options=options)
"""
# chromium
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
options.add_argument("--headless")
options.binary_location = "/usr/bin/chromium-browser"
cls.selenium = webdriver.Chrome(chrome_options=options)
@classmethod
def tearDownClass(cls):
#zamykamy przeglądarkę
cls.selenium.quit()
super().tearDownClass()
class AuthenticationTests(BaseAuthentication):
def runTest(self):
#tworzenie użytkownika
user = User.objects.create_superuser(self.username, self.email, self.password)
user.save()
#próba zalogowania
self.selenium.get("%s/admin" % self.live_server_url)
self.selenium.find_element_by_id("id_auth-username").send_keys(self.username)
self.selenium.find_element_by_id("id_auth-password").send_keys(self.password)
self.selenium.find_element_by_css_selector("button[type='submit']").click()
#czekamy aż załaduje się strona panelu
WebDriverWait(self.selenium, 2).until(lambda driver: driver.find_element_by_css_selector("#content h1"))
#sprawdzamy czy jesteśmy na stronie panelu
self.assertEqual("Site administration", self.selenium.find_element_by_css_selector("#content h1").text)
class RegistrationTests(BaseAuthentication):
def runTest(self):
self.selenium.get(self.live_server_url)
self.selenium.find_element(By.LINK_TEXT, "registering").click()
WebDriverWait(self.selenium, 2).until(lambda driver: driver.find_element(By.ID, "id_username"))
self.selenium.find_element(By.ID, "id_username").send_keys(self.username)
self.selenium.find_element(By.ID, "id_password1").send_keys(self.password)
self.selenium.find_element(By.ID, "id_password2").send_keys(self.password)
self.selenium.find_element(By.CSS_SELECTOR, ".btn").click()
WebDriverWait(self.selenium, 2).until(lambda driver: driver.find_element(By.LINK_TEXT, "Login"))
user = User.objects.get(username=self.username)
self.assertTrue(user.check_password(self.password))
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team