-
Notifications
You must be signed in to change notification settings - Fork 0
/
test12_dynamic_content.py
66 lines (52 loc) · 2.68 KB
/
test12_dynamic_content.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import unittest
import urllib3
import requests
import pyautogui
from time import sleep
from pynput.keyboard import Key, Controller
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
# PATH = Service("C:\\Users\\marius\\chromedriver.exe")
s = Service(ChromeDriverManager().install())
url = "https://the-internet.herokuapp.com/"
# action_chains = ActionChains(driver)
# alert = Alert(driver)
expected_title = 'Dynamic Content'
static_text_1 = "Accusantium eius ut architecto neque vel voluptatem vel nam eos minus ullam dolores voluptates enim sed voluptatem rerum qui sapiente nesciunt aspernatur et accusamus laboriosam culpa tenetur hic aut placeat error autem qui sunt."
static_text_2 = "Omnis fugiat porro vero quas tempora quis eveniet ab officia cupiditate culpa repellat debitis itaque possimus odit dolorum et iste quibusdam quis dicta autem sint vel quo vel consequuntur dolorem nihil neque sunt aperiam blanditiis."
static_image_1 = "/img/avatars/Original-Facebook-Geek-Profile-Avatar-2.jpg"
static_image_2 = "/img/avatars/Original-Facebook-Geek-Profile-Avatar-7.jpg"
dynamic_images = ["/img/avatars/Original-Facebook-Geek-Profile-Avatar-1.jpg", "/img/avatars/Original-Facebook-Geek-Profile-Avatar-3.jpg", "/img/avatars/Original-Facebook-Geek-Profile-Avatar-5.jpg"]
class DynamicContent(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome(service=s)
driver = self.driver
driver.get(url)
driver.maximize_window()
WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.TAG_NAME, "h1")))
driver.find_element(by=By.XPATH, value="/html/body/div[2]/div/ul/li[12]/a").click()
driver.find_element(by=By.XPATH, value='/html/body/div[2]/div/div/p[2]/a').click()
def test_title_is_correct(self):
driver = self.driver
title = driver.find_element(by=By.CSS_SELECTOR, value="h3").text
self.assertEqual(title, expected_title)
def test_static_text(self):
pass
def test_static_images(self):
pass
def test_dynamic_text(self):
pass
def test_dynamic_images(self):
pass
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()