-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ab wo login wala test headless ke sath chlane ki koshsish
- Loading branch information
1 parent
2acd981
commit 4db2b53
Showing
2 changed files
with
41 additions
and
38 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
|
@@ -6,51 +6,54 @@ | |
import time | ||
import django | ||
|
||
class Hosttest(LiveServerTestCase): | ||
# class Hosttest(LiveServerTestCase): | ||
|
||
def testhomepage(self): | ||
# def testhomepage(self): | ||
|
||
options = Options() | ||
options.headless = True | ||
driver = webdriver.Chrome(options=options) | ||
# options = Options() | ||
# options.headless = True | ||
# driver = webdriver.Chrome(options=options) | ||
|
||
driver.get(self.live_server_url) | ||
# try driver.get(self.live_server_url) if driver.get('http://127.0.0.1:8000/') does not work | ||
# driver.get(self.live_server_url) | ||
# # try driver.get(self.live_server_url) if driver.get('http://127.0.0.1:8000/') does not work | ||
|
||
assert "Hello, world!" in driver.title | ||
# assert "Hello, world!" in driver.title | ||
|
||
# class LoginFormTest(LiveServerTestCase): | ||
class LoginFormTest(LiveServerTestCase): | ||
|
||
|
||
# port = 8000 | ||
# host = '127.0.0.1' | ||
# def setUp(self): | ||
# self.selenium = webdriver.Chrome(executable_path="/Users/mueezkhan/django-test/chromedriver") | ||
# super(LoginFormTest, self).setUp() | ||
port = 8000 | ||
host = '127.0.0.1' | ||
# def setUp(self): | ||
# self.selenium = webdriver.Chrome(executable_path="/Users/mueezkhan/django-test/chromedriver") | ||
# super(LoginFormTest, self).setUp() | ||
|
||
# def tearDown(self): | ||
# self.selenium.quit() | ||
# super(LoginFormTest, self).tearDown() | ||
# def tearDown(self): | ||
# self.selenium.quit() | ||
# super(LoginFormTest, self).tearDown() | ||
|
||
# def testform(self): | ||
# driver = self.selenium | ||
# # super(LoginFormTest, self).setUp() | ||
# driver.get(f"http://127.0.0.1:8000/accounts/login") | ||
|
||
# # user = User.objects.create_user('kamil', '[email protected]', 'kamil') | ||
|
||
# # print(user) | ||
# # time.sleep(1) | ||
# user_name = driver.find_element_by_name('username') | ||
# user_password = driver.find_element_by_name('password') | ||
# time.sleep(3) | ||
# submit = driver.find_element_by_id('submit') | ||
|
||
# user_name.send_keys('kamil') | ||
# user_password.send_keys('kamil') | ||
|
||
# submit.send_keys(Keys.RETURN) | ||
# time.sleep(3) | ||
# print(driver.page_source) | ||
# assert 'kamil' in driver.page_source | ||
def testform(self): | ||
options = Options() | ||
options.headless = True | ||
driver = webdriver.Chrome(options=options) | ||
# driver = self.selenium | ||
# super(LoginFormTest, self).setUp() | ||
driver.get(f"http://127.0.0.1:8000/accounts/login") | ||
|
||
# user = User.objects.create_user('kamil', '[email protected]', 'kamil') | ||
|
||
# print(user) | ||
# time.sleep(1) | ||
user_name = driver.find_element_by_name('username') | ||
user_password = driver.find_element_by_name('password') | ||
time.sleep(3) | ||
submit = driver.find_element_by_id('submit') | ||
|
||
user_name.send_keys('kamil') | ||
user_password.send_keys('kamil') | ||
|
||
submit.send_keys(Keys.RETURN) | ||
time.sleep(3) | ||
print(driver.page_source) | ||
assert 'User: kamil' in driver.page_source | ||
|