-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_sketch_modal_improvement.py
More file actions
63 lines (53 loc) · 2.56 KB
/
test_sketch_modal_improvement.py
File metadata and controls
63 lines (53 loc) · 2.56 KB
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
from codebender_testing.utils import SeleniumTestCase
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from codebender_testing import config
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from codebender_testing.config import TIMEOUT
from selenium.webdriver.support.ui import WebDriverWait
import pytest
class TestSketchesCounters(SeleniumTestCase):
@pytest.fixture(scope="class", autouse=True)
def open_user_home(self, tester_login):
"""Makes sure we are logged in and are at the user home page
performing any of these tests."""
pass
def test_create_sketch_modal(self):
# Create a public project.
createSketchBtn = self.get_element(By.ID, 'create_sketch_btn')
createSketchBtn.click()
WebDriverWait(self.driver, TIMEOUT['LOCATE_ELEMENT']).until(
expected_conditions.visibility_of_element_located(
(By.CSS_SELECTOR, "#create-sketch-modal")
)
)
createBtn = self.get_element(
By.ID, 'create-sketch-modal-action-button')
createdProject = self.get_element(
By.ID, 'create-sketch-name').get_attribute('value')
# Check that when the create sketch modal opens,
# the sketch name input has focus.
assert self.get_element(By.ID, 'create-sketch-name') == \
self.driver.switch_to.active_element
# Check that when the input has focus and you press Enter,
# the create sketch action is executed.
self.get_element(By.ID, 'create-sketch-name').send_keys(Keys.ENTER)
self.get_element(By.CSS_SELECTOR, '#create-sketch-modal-action-button .fa-spinner')
# Check that during the sketch creation,
# the sketch privacy radio buttons are disabled.
publicRadioButton = self.get_element(By.CSS_SELECTOR,
'#create-sketch-modal-type-controls [value="public"]')
privateRadioButton = self.get_element(By.CSS_SELECTOR,
'#create-sketch-modal-type-controls [value="private"]')
assert publicRadioButton.get_attribute('disabled')
assert privateRadioButton.get_attribute('disabled')
WebDriverWait(self.driver, TIMEOUT['LOCATE_ELEMENT']).until(
expected_conditions.element_to_be_clickable(
(By.CSS_SELECTOR, "#editor_heading_project_name")
)
)
# Delete the created project.
self.open("/")
self.delete_project(createdProject)