blob: 725e858e66ed9b5c80141700f4d3a884274a142b (
plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# Toaster setup test case
#
# Copyright (C) 2015-2016 Intel Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import time
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium import selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from toaster.tests.base import ToasterTestCase
class ToasterSetupTestCase(ToasterTestCase):
def setUp(self):
self.driver = webdriver.Firefox()
def tearDown(self):
self.driver.close()
def is_text_present (self, patterns):
for pattern in patterns:
if str(pattern) not in self.driver.page_source:
self.logger.debug(pattern)
return False
return True
def test_setupToaster(self):
self.driver.maximize_window()
self.driver.get(self.opts.toaster_url)
try:
self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
except:
self.driver.find_element_by_id("new-project-button").click()
self.driver.find_element_by_id("new-project-name").send_keys("selenium-project")
self.driver.find_element_by_id("create-project-button").click()
try:
self.driver.find_element_by_link_text("selenium-project").click()
except:
self.driver.find_element_by_id("new-project-button").click()
self.driver.find_element_by_id("new-project-name").send_keys("selenium-project")
self.driver.find_element_by_id("create-project-button").click()
time.sleep(5)
#queue up a core-image-minimal
self.driver.find_element_by_id("build-input").send_keys("core-image-minimal")
self.driver.find_element_by_id("build-button").click()
time.sleep(5)
#queue up a core-image-sato
self.driver.find_element_by_id("build-input").send_keys("core-image-sato")
self.driver.find_element_by_id("build-button").click()
time.sleep(5)
#go back to the main project page
self.driver.find_element_by_css_selector("a[href='/toastergui/projects/']").click()
time.sleep(5)
self.driver.find_element_by_link_text("selenium-project").click()
time.sleep(5)
#move to all builds page
self.driver.find_element_by_css_selector("a[href='/toastergui/builds/']").click()
self.driver.refresh()
time.sleep(5)
#check progress bar is displayed to signal a build has started
try:
while (self.driver.find_element_by_xpath("//div[@class='progress']").is_displayed()):
self.logger.info('Builds are running ...')
self.driver.refresh()
time.sleep(15)
except:
pass
self.logger.info("Looking for successful build...")
if (self.driver.find_element_by_xpath("//div[@class='alert build-result alert-success project-name']").is_displayed()):
self.logger.info("Builds complete!")
else:
self.fail(msg="Builds did not complete successfully.")
|