3 # Copyright 2017 RIFT.IO Inc
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
21 from selenium
.webdriver
.support
.ui
import WebDriverWait
22 from selenium
.webdriver
.support
import expected_conditions
as EC
23 from selenium
.webdriver
.common
.by
import By
26 gi
.require_version('RwUserYang', '1.0')
27 gi
.require_version('RwProjectYang', '1.0')
28 gi
.require_version('RwConmanYang', '1.0')
30 from gi
.repository
import (
36 gi
.require_version('RwKeyspec', '1.0')
37 from gi
.repository
.RwKeyspec
import quoted_key
40 class TestGUI(object):
43 def click_element_and_wait(self
, driver
, key_word
, wait
=True):
44 """Click and wait for that element to appear."""
45 path
= "//a[text()={}]".format(quoted_key(key_word
))
46 driver
.find_element_by_xpath(path
).click()
48 WebDriverWait(driver
, 10).until(
49 EC
.presence_of_element_located((
52 def click_button(self
, driver
, key_word
):
54 path
= "//div[text()={}]".format(quoted_key(key_word
))
55 driver
.find_element_by_xpath(path
).click()
57 def input_value(self
, driver
, data_reactid
, value
):
58 """Input values to field."""
59 path
= "//input[@data-reactid={}]".format(quoted_key(data_reactid
))
60 driver
.find_element_by_xpath(path
).send_keys(value
)
62 def test_basic_checks(
63 self
, driver
, logger
, rw_project_proxy
, rw_user_proxy
):
64 """test_basic_checks."""
65 logger
.debug('Check access to all basic pages.')
67 ['Accounts', 'Catalog', 'Launchpad', 'ADMINISTRATION',
68 'PROJECT: default', 'admin'])
69 for key_word
in basic_pages
:
70 self
.click_element_and_wait(driver
, key_word
)
72 logger
.debug('Create a test project.')
73 self
.click_element_and_wait(driver
, 'ADMINISTRATION')
74 self
.click_element_and_wait(driver
, 'Project Management', wait
=False)
75 self
.click_button(driver
, 'Add Project')
76 self
.input_value(driver
, '.0.4.0.1.0.4.0.0.1.0.1', 'test_project')
77 self
.click_button(driver
, 'Create')
79 logger
.debug('Verify test project is created in ui.')
80 path
= "//div[text()={}]".format(quoted_key('test_project'))
81 WebDriverWait(driver
, 10).until(
82 EC
.presence_of_element_located((
85 logger
.debug('Verify test project is created in config.')
86 project_cm_config_xpath
= '/project[name={}]/project-state'
87 project_
= rw_project_proxy
.get_config(
88 project_cm_config_xpath
.format(
89 quoted_key('test_project')), list_obj
=True)
92 logger
.debug('Create a test user.')
93 self
.click_element_and_wait(driver
, 'ADMINISTRATION')
94 self
.click_element_and_wait(driver
, 'User Management', wait
=False)
95 self
.click_button(driver
, 'Add User')
96 self
.input_value(driver
, '.0.4.0.1.1.0.4.0.0.1.0.1', 'test_user')
97 self
.input_value(driver
, '.0.4.0.1.1.0.4.0.3.1.0.1', 'mypasswd')
98 self
.input_value(driver
, '.0.4.0.1.1.0.4.0.3.1.1.1', 'mypasswd')
99 self
.click_button(driver
, 'Create')
101 logger
.debug('Verify test user is created in ui.')
102 path
= "//div[text()={}]".format(quoted_key('test_user'))
103 WebDriverWait(driver
, 10).until(
104 EC
.presence_of_element_located((
107 logger
.debug('Verify test user is created in config.')
108 user_config_xpath
= (
109 '/user-config/user[user-name={user_name}][user-domain={domain}]')
110 user_
= rw_user_proxy
.get_config(
111 user_config_xpath
.format(
112 user_name
=quoted_key('test_user'),
113 domain
=quoted_key('system')))