Fakultas Ilmu Komputer UI

Commit ff75b9fe authored by Izzatul Muttaqin's avatar Izzatul Muttaqin
Browse files

Tutorial 3 done

parent 1343e3fe
Pipeline #21716 failed with stage
in 1 minute and 39 seconds
# 1606837915-practice
[Izzatul Muttaqin - PMPL A](https://pmpl-project.herokuapp.com/)
## Latihan 3
Test isolation yang dilakukan adalah test dapat berjalan sesuai dengan request dari url liveserver bukan dari url yang ditentukan pada awal yaitu localhost
Fitur yang ditambahkan adalah proses menunggu 10 detik tidak dilakukan hanya dengan serta merta menunggu melainkan dengan proses menunggu dari webdriver hingga input muncul selama 10 detik
\ No newline at end of file
......@@ -5,54 +5,39 @@ from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.chrome.options import Options
from django.test import LiveServerTestCase
import time
import unittest
import environ
root = environ.Path(__file__)
env = environ.Env(DEBUG=(bool, False), )
environ.Env.read_env('.env')
HEROKU_APP_HOST = env("HEROKU_APP_HOST")
print("HEROKU_APP_HOST is", HEROKU_APP_HOST)
MAX_WAIT = 5
class NewVisitorTest(unittest.TestCase):
class NewVisitorTest(LiveServerTestCase):
def setUp(self):
chrome_options = Options()
chrome_options.add_argument('--dns-prefetch-disable')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('disable-gpu')
try:
self.browser = webdriver.Chrome('./chromedriver.exe', chrome_options=chrome_options)
except:
self.browser = webdriver.Chrome('./chromedriver', chrome_options=chrome_options)
super(NewVisitorTest, self).setUp()
self.browser = webdriver.Chrome()
def tearDown(self):
self.browser.close()
self.browser.quit()
def check_for_row(self, row_text):
table = self.browser.find_element_by_id('id_list_table')
rows = table.find_elements_by_tag_name('tr')
self.assertIn(row_text, [row.text for row in rows])
def test_assert_name(self):
self.browser.get(HEROKU_APP_HOST)
introduction = self.browser.find_element_by_id("intro")
self.assertIn('Izzatul', introduction.text)
def test_can_start_a_list_and_retrieve_it_later(self):
self.browser.get(HEROKU_APP_HOST)
self.browser.get(self.live_server_url)
self.assertIn('To-Do', self.browser.title)
header_text = self.browser.find_element_by_tag_name('h1').text
self.assertIn('To-Do', header_text)
introduction = self.browser.find_element_by_id("intro")
self.assertIn('Izzatul', introduction.text)
comment = self.browser.find_element_by_id('comment')
self.assertEqual(comment.text, 'yey, waktunya libur')
inputbox = self.browser.find_element_by_id('id_new_item')
self.assertEqual(
inputbox.get_attribute('placeholder'),
......
......@@ -8,7 +8,7 @@
{% csrf_token %}
</form>
<h1>{{ comment }}</h1>
<h1 id="comment">{{ comment }}</h1>
<table id="id_list_table">
{% for item in items %}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment