-
-
Save els-pnw/1608188 to your computer and use it in GitHub Desktop.
<div id="system_97" class="block tall" data-ajax_url="/headpin/systems/97/edit" style="width: 358px;"> | |
<div> | |
<div class="column_2"> | |
<div class="product"> | |
<div class="one-line-ellipsis" style="padding-top: 2px;"> newsystem2820 </div> | |
</div> | |
<div class="column_2"> Never checked in. </div> | |
</div> | |
<div> | |
<div class="arrow-right"></div> | |
</div> |
#!/usr/bin/env python | |
... | |
class Systems(Base): | |
_systems_search_form_locator = (By.XPATH, "//form[@id='search_form']") | |
_systems_search_input_locator = (By.XPATH, "//input[@id='search']") | |
_systems_search_button_locator = (By.XPATH, "//button[@id='search_button']") | |
_systems_create_new_locator = (By.XPATH, "//a[@id='new']") | |
_systems_list_box_locator = (By.XPATH, "//div[@id='list']") | |
_systems_server_name_locator = (By.XPATH, "//div[@class='one-line-ellipsis']") | |
_new_systemname_field_locator = (By.XPATH, "//input[@id='name_field']") | |
_new_system_arch_select_locator = (By.XPATH, "//select[@id='arch_arch_id']") | |
_new_system_sockets_field_locator = (By.XPATH, "//input[@id='sockets_field']") | |
_new_system_virt_select_locator = (By.XPATH, "//input[@value='virtual']") | |
_new_system_physical_select_locator = (By.XPATH, "//input[@value='physical']") | |
## Need to add Environment elements here | |
_new_system_save_locator = (By.XPATH, "//input[@id='system_save']") | |
_facts_tab_locator = (By.XPATH, "//a[.='Facts']") | |
_details_tab_locator = (By.XPATH, "//a[.='Details']") | |
_software_tab_locator = (By.XPATH, "//a[.='Software']") | |
_subscriptions_tab_locator = (By.XPATH, "//a[.='Subscriptions']") | |
_system_details_name_locator = "" | |
_success_message = (By.XPATH, "//div[contains(@class,'jnotify-notification-message')]") | |
_system_list_locator = (By.CSS_SELECTOR, "div.block.tall") | |
def system(self, value): | |
for system in self.systems: | |
print system | |
if system.name == value: | |
return system | |
raise Exception('System not found: %s' % value) | |
@property | |
def systems(self): | |
return [self.Systems(self.testsetup, element) for element in self.selenium.find_elements(*self._system_list_locator)] | |
class Systems(Page): | |
_name_locator = (By.XPATH, "//div[@class='one-line-ellipsis']") | |
def __init__(self, testsetup, element): | |
Page.__init__(self, testsetup) | |
self._root_element = element | |
@property | |
def name(self): | |
return self._root_element.find_element(*self._name_locator).text |
#!/usr/bin/env python | |
import pytest | |
from unittestzero import Assert | |
from pages.home import Home | |
from pages.systems import Systems | |
import time | |
import sys | |
nondestructive = pytest.mark.nondestructive | |
destructive = pytest.mark.destructive | |
class TestSystems: | |
@nondestructive | |
def test_create_new_virt_system(self, mozwebqa): | |
home_page = Home(mozwebqa) | |
home_page.login() | |
Assert.true(home_page.header.is_user_logged_in) | |
home_page.tabs.click_tab("systems_tab") | |
Assert.true(home_page.is_the_current_page) | |
systems = Systems(mozwebqa) | |
new_system_name = systems.unique_system_name() | |
systems.create_new_virt_system(new_system_name) | |
Assert.true(systems.system(new_system_name)) |
pydev debugger: starting
============================= test session starts ==============================
platform linux2 -- Python 2.7.1 -- pytest-2.1.3
collecting ... collected 1 items
tests/test_systems.py F
=================================== FAILURES ===================================
___________________ TestSystems.test_create_new_virt_system ____________________
self = <tests.test_systems.TestSystems instance at 0x1c198c0>
mozwebqa = <mozwebqa.mozwebqa.TestSetup instance at 0x1c23b90>
@nondestructive
def test_create_new_virt_system(self, mozwebqa):
home_page = Home(mozwebqa)
home_page.login()
Assert.true(home_page.header.is_user_logged_in)
home_page.tabs.click_tab("systems_tab")
Assert.true(home_page.is_the_current_page)
systems = Systems(mozwebqa)
new_system_name = systems.unique_system_name()
systems.create_new_virt_system(new_system_name)
Assert.true(systems.system(new_system_name))
tests/test_systems.py:29:
self = <class unittestzero.Assert at 0x1bb0a10>
first = <pages.systems.Systems object at 0x1d25390>, msg = None
@classmethod
def true(self, first, msg=None):
assert first is True, msg
E assert <pages.systems.Systems object at 0x1d25390> is True
/usr/lib/python2.7/site-packages/unittestzero.py:53: AssertionError
========================== 1 failed in 390.46 seconds ==========================
ests/test_systems.py F
=================================== FAILURES ===================================
___________________ TestSystems.test_create_new_virt_system ____________________
self = <tests.test_systems.TestSystems instance at 0x22be998>
mozwebqa = <mozwebqa.mozwebqa.TestSetup instance at 0x22c7bd8>
@nondestructive
def test_create_new_virt_system(self, mozwebqa):
home_page = Home(mozwebqa)
home_page.login()
Assert.true(home_page.header.is_user_logged_in)
home_page.tabs.click_tab("systems_tab")
Assert.true(home_page.is_the_current_page)
systems = Systems(mozwebqa)
new_system_name = systems.unique_system_name()
systems.create_new_virt_system(new_system_name)
print [new_system_name]
print systems.systems
time.sleep(20)
print [system.name for system in systems.systems]
Assert.true(systems.system(new_system_name))
tests/test_systems.py:32:
self = <class unittestzero.Assert at 0x22a1530>
first = <pages.systems.Systems object at 0x23107d0>, msg = None
@classmethod
def true(self, first, msg=None):
assert first is True, msg
E assert <pages.systems.Systems object at 0x23107d0> is True
/usr/lib/python2.7/site-packages/unittestzero.py:53: AssertionError
------------------------------- Captured stdout --------------------------------
['newsystem43378']
[<pages.systems.Systems object at 0x22c6c10>]
[u'newsystem43378', u'newsystem1015', u'newsystem1364', u'newsystem1648', u'newsystem1972', u'newsystem19907', u'newsystem25472', u'newsystem2820', u'newsystem31362', u'newsystem34533', u'newsystem38110', u'newsystem39604', u'newsystem40151', u'newsystem41958', u'newsystem43523', u'newsystem45583', u'newsystem4706', u'newsystem48514', u'newsystem51033', u'newsystem51161', u'newsystem51327', u'newsystem56143', u'newsystem58093', u'newsystem59016', u'newsystem5919', u'newsystem70240']
========================== 1 failed in 36.43 seconds ===========================
============================= test session starts ==============================
platform linux2 -- Python 2.7.1 -- pytest-2.1.3
collecting ... collected 1 items
tests/test_systems.py F
=================================== FAILURES ===================================
___________________ TestSystems.test_create_new_virt_system ____________________
self = <tests.test_systems.TestSystems instance at 0x1fd3950>
mozwebqa = <mozwebqa.mozwebqa.TestSetup instance at 0x1fdcb90>
@nondestructive
def test_create_new_virt_system(self, mozwebqa):
home_page = Home(mozwebqa)
home_page.login()
Assert.true(home_page.header.is_user_logged_in)
home_page.tabs.click_tab("systems_tab")
Assert.true(home_page.is_the_current_page)
systems = Systems(mozwebqa)
new_system_name = systems.unique_system_name()
systems.create_new_virt_system(new_system_name)
print [new_system_name]
print systems.systems
time.sleep(20)
print [system.name for system in systems.systems]
system = systems.system(new_system_name); assert system is True
E assert <pages.systems.Systems object at 0x20a6110> is True
tests/test_systems.py:32: AssertionError
------------------------------- Captured stdout --------------------------------
['newsystem41465']
[<pages.systems.Systems object at 0x1fdbc90>]
[u'newsystem41465', u'newsystem1015', u'newsystem1364', u'newsystem1648', u'newsystem1972', u'newsystem19907', u'newsystem22200', u'newsystem25472', u'newsystem2820', u'newsystem31362', u'newsystem34533', u'newsystem38110', u'newsystem39604', u'newsystem40151', u'newsystem41958', u'newsystem43378', u'newsystem43523', u'newsystem45583', u'newsystem4706', u'newsystem48514', u'newsystem51033', u'newsystem51161', u'newsystem51327', u'newsystem56143', u'newsystem58093', u'newsystem59016']
========================== 1 failed in 37.69 seconds ===========================
============================= test session starts ==============================
platform linux2 -- Python 2.7.1 -- pytest-2.1.3
collecting ... collected 1 items
tests/test_systems.py F
=================================== FAILURES ===================================
___________________ TestSystems.test_create_new_virt_system ____________________
self = <tests.test_systems.TestSystems instance at 0x1fd3950>
mozwebqa = <mozwebqa.mozwebqa.TestSetup instance at 0x1fdcb90>
@nondestructive
def test_create_new_virt_system(self, mozwebqa):
home_page = Home(mozwebqa)
home_page.login()
Assert.true(home_page.header.is_user_logged_in)
home_page.tabs.click_tab("systems_tab")
Assert.true(home_page.is_the_current_page)
systems = Systems(mozwebqa)
new_system_name = systems.unique_system_name()
systems.create_new_virt_system(new_system_name)
print [new_system_name]
print systems.systems
time.sleep(20)
print [system.name for system in systems.systems]
system = systems.system(new_system_name); assert system is True
E assert <pages.systems.Systems object at 0x20a6110> is True
tests/test_systems.py:32: AssertionError
------------------------------- Captured stdout --------------------------------
['newsystem41465']
[<pages.systems.Systems object at 0x1fdbc90>]
[u'newsystem41465', u'newsystem1015', u'newsystem1364', u'newsystem1648', u'newsystem1972', u'newsystem19907', u'newsystem22200', u'newsystem25472', u'newsystem2820', u'newsystem31362', u'newsystem34533', u'newsystem38110', u'newsystem39604', u'newsystem40151', u'newsystem41958', u'newsystem43378', u'newsystem43523', u'newsystem45583', u'newsystem4706', u'newsystem48514', u'newsystem51033', u'newsystem51161', u'newsystem51327', u'newsystem56143', u'newsystem58093', u'newsystem59016']
========================== 1 failed in 37.69 seconds ===========================
self = <pages.systems.Systems object at 0x11929d0>, value = 'newsystem25472'
pages/systems.py:100: Exception
========================== 1 failed in 14.58 seconds ===========================