Skip to content

Commit

Permalink
ab wo login wala test headless ke sath chlane ki koshsish
Browse files Browse the repository at this point in the history
  • Loading branch information
MueezKhan246 committed Jan 11, 2022
1 parent 2acd981 commit 4db2b53
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
Binary file modified db.sqlite3
Binary file not shown.
79 changes: 41 additions & 38 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4db2b53

Please sign in to comment.