2 # Copyright 2017 RIFT.IO Inc
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
20 from pyvirtualdisplay
import Display
21 from selenium
import webdriver
22 from selenium
.webdriver
.support
.ui
import WebDriverWait
23 from selenium
.webdriver
.support
import expected_conditions
as EC
24 from selenium
.webdriver
.common
.by
import By
26 gi
.require_version('RwCloudYang', '1.0')
27 gi
.require_version('RwConfigAgentYang', '1.0')
28 gi
.require_version('RwSdnYang', '1.0')
30 from gi
.repository
import (
36 gi
.require_version('RwKeyspec', '1.0')
37 from gi
.repository
.RwKeyspec
import quoted_key
40 @pytest.fixture(scope
='session')
41 def cloud_proxy(mgmt_session
):
43 return mgmt_session
.proxy(RwCloudYang
)
46 @pytest.fixture(scope
='session')
47 def sdn_proxy(mgmt_session
):
49 return mgmt_session
.proxy(RwSdnYang
)
52 @pytest.fixture(scope
='session')
53 def config_agent_proxy(mgmt_session
):
54 """config_agent_proxy."""
55 return mgmt_session
.proxy(RwConfigAgentYang
)
58 @pytest.fixture(scope
='session')
59 def driver(request
, confd_host
, logger
):
60 """Set up virtual diplay and browser driver."""
61 # Set up the virtual display
62 display
= Display(visible
=0, size
=(1024, 768))
65 logger
.info("Initializing the chrome web driver")
66 root_dir
= os
.environ
.get('RIFT_ROOT')
67 webdriver_path
= '{}/chromedriver'.format(root_dir
)
68 # webdriver_path = os.environ["webdriver.chrome.driver"]
69 # Something like this should be implemented.
71 driver_
= webdriver
.Chrome(executable_path
=webdriver_path
)
72 driver_
.implicitly_wait(5)
73 url
= "http://{}:8000/".format(confd_host
)
74 logger
.info("Getting the URL {}".format(url
))
76 WebDriverWait(driver_
, 10).until(
77 EC
.presence_of_element_located((By
.CLASS_NAME
, "logo"))
80 logger
.info("Signing into the Rift home page")
81 driver_
.find_element_by_name("username").send_keys("admin")
82 driver_
.find_element_by_name("password").send_keys("admin")
83 driver_
.find_element_by_id("submit").click()
84 WebDriverWait(driver_
, 10).until(
85 EC
.presence_of_element_located((By
.CLASS_NAME
, "skyquakeNav"))