-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8ee64e
commit 2218ad6
Showing
5 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ pytest~=7.1.2 | |
filetype==1.2.0 | ||
language-tool-python==2.7.1 | ||
markdown==3.4.4 | ||
selenium==4.16.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import unittest | ||
from selenium import webdriver | ||
from selenium.webdriver.firefox.service import Service as FirefoxService | ||
from webdriver_manager.firefox import GeckoDriverManager | ||
from selenium.webdriver.firefox.options import Options | ||
|
||
class BasicSeleniumTest(unittest.TestCase): | ||
|
||
# options = Options() | ||
# options.binary_location = r'~/home/snap/bin/firefox' | ||
# driver = webdriver.Firefox(options=options) | ||
|
||
driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install())) | ||
|
||
def __init__(self, methodName='runTest', param=None): | ||
super(BasicSeleniumTest, self).__init__(methodName) | ||
self.param = param | ||
|
||
@staticmethod | ||
def parametrize(testcase_klass, param=None): | ||
testloader = unittest.TestLoader() | ||
testnames = testloader.getTestCaseNames(testcase_klass) | ||
suite = unittest.TestSuite() | ||
for name in testnames: | ||
suite.addTest(testcase_klass(name, param=param)) | ||
return suite | ||
|
||
def getUrl(self, relativePath): | ||
return self.param + relativePath | ||
|
||
def getDriver(_): | ||
return BasicSeleniumTest.driver | ||
|
||
@classmethod | ||
def closeDriver(cls): | ||
cls.driver.close() | ||
|
||
|
||
|
||
# def setUp(self): | ||
# self.driver = webdriver.Firefox() # Chrome() | ||
|
||
# def tearDown(self): | ||
# self.driver.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import unittest | ||
import sys | ||
from basic_selenium_test import BasicSeleniumTest | ||
from test_authorization import AuthTestSelenium | ||
|
||
|
||
def main(host): | ||
suite = unittest.TestSuite() | ||
|
||
suite.addTest( | ||
BasicSeleniumTest.parametrize( | ||
AuthTestSelenium, | ||
param=host)) | ||
|
||
returnCode = not unittest.TextTestRunner( | ||
verbosity=2).run(suite).wasSuccessful() | ||
|
||
BasicSeleniumTest.closeDriver() | ||
sys.exit(returnCode) | ||
|
||
|
||
if __name__ == '__main__': | ||
host_arg = 'https://slides-checker.moevm.info' | ||
main(host_arg) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import unittest | ||
import time | ||
from basic_selenium_test import BasicSeleniumTest | ||
from selenium.webdriver.common.by import By | ||
|
||
# AUTH_URL = 'https://slides-checker.moevm.info/login' | ||
|
||
class AuthTestSelenium(BasicSeleniumTest): | ||
|
||
def test_loading(self): | ||
URL = self.getUrl('/login') | ||
self.getDriver().get(URL) | ||
self.getDriver().implicitly_wait(30) | ||
obj = self.getDriver().find_element(By.CLASS_NAME, "form-group") | ||
self.assertNotEquals(obj, None) | ||
return True | ||
|
||
|
||
def failed_auth(self): | ||
URL = self.getUrl('/login') | ||
self.getDriver().get(URL) | ||
self.getDriver().implicitly_wait(30) | ||
|
||
login = self.getDriver().find_element(By.ID, "login_text_field") | ||
login.clear() | ||
login.send_keys('wrong_login') | ||
|
||
password = self.getDriver().find_element(By.ID, "password_text_field") | ||
password.clear() | ||
password.send_keys('wrong_password') | ||
|
||
login_button = self.getDriver().find_element(By.ID, "login_button") | ||
login_button.click() | ||
obj = self.getDriver().find_element(By.CLASS_NAME, "invalid-feedback ins") | ||
self.assertNotEquals(obj, None) | ||
|