Fix UI locators on settings tab

Change-Id: I1866d0b4d35c5b57b2e4acfeb143d72242a6ed9d
This commit is contained in:
asledzinskiy 2014-04-02 10:46:07 +03:00
parent 4f951a668f
commit f0be16258f
5 changed files with 93 additions and 52 deletions

View File

@ -85,10 +85,20 @@ class PageObject:
@staticmethod @staticmethod
def click_element(page_object, *args): def click_element(page_object, *args):
# get the list of attributes passed to the method
attributes = [attribute for attribute in args] attributes = [attribute for attribute in args]
attempts = 0 attempts = 0
while attempts < 3: while attempts < 5:
try: try:
"""1, 3, 4 are the number of passed to the method attributes
1 means that only class name and one property
were passed to the method
3 means that class name, two properties and index
of the element were passed to the method
4 means that class name, three properties and index
of the element were passed to the method
"""
if len(attributes) == 1: if len(attributes) == 1:
getattr(page_object, attributes[0]).click() getattr(page_object, attributes[0]).click()
elif len(attributes) == 3: elif len(attributes) == 3:
@ -99,29 +109,50 @@ class PageObject:
attributes[0])[attributes[3]], attributes[0])[attributes[3]],
attributes[1]), attributes[2]).click() attributes[1]), attributes[2]).click()
break break
except StaleElementReferenceException: except (StaleElementReferenceException, NoSuchElementException):
pass time.sleep(0.5)
attempts += 1 attempts += 1
@staticmethod @staticmethod
def find_element(page_object, *args): def find_element(page_object, *args):
attributes = [attribute for attribute in args] attributes = [attribute for attribute in args]
attempts = 0 attempts = 0
while attempts < 3: while attempts < 5:
try: try:
if len(attributes) == 1: if len(attributes) == 1:
getattr(page_object, attributes[0]) return getattr(page_object, attributes[0])
elif len(attributes) == 3: elif len(attributes) == 3:
getattr(getattr(page_object, return getattr(getattr(page_object,
attributes[0])[attributes[2]], attributes[0])[attributes[2]],
attributes[1]) attributes[1])
elif len(attributes) == 4: elif len(attributes) == 4:
getattr(getattr(getattr(page_object, return getattr(getattr(getattr(page_object,
attributes[0])[attributes[3]], attributes[0])[attributes[3]],
attributes[1]), attributes[2]) attributes[1]), attributes[2])
break break
except StaleElementReferenceException: except (StaleElementReferenceException, NoSuchElementException):
pass time.sleep(0.5)
attempts += 1
@staticmethod
def get_text(page_object, *args):
attributes = [attribute for attribute in args]
attempts = 0
while attempts < 5:
try:
if len(attributes) == 1:
return getattr(page_object, attributes[0]).text
elif len(attributes) == 3:
return getattr(getattr(page_object,
attributes[0])[attributes[2]],
attributes[1]).text
elif len(attributes) == 4:
return getattr(getattr(getattr(page_object,
attributes[0])[attributes[3]],
attributes[1]), attributes[2]).text
break
except (StaleElementReferenceException, NoSuchElementException):
time.sleep(0.5)
attempts += 1 attempts += 1

View File

@ -145,7 +145,7 @@ class Wizard(Popup, RedhatAccountPopup):
def install_savanna(self): def install_savanna(self):
return self.parent.\ return self.parent.\
find_element_by_xpath( find_element_by_xpath(
self.XPATH_CHECKBOX.format('savanna')) self.XPATH_CHECKBOX.format('sahara'))
@property @property
def install_murano(self): def install_murano(self):

View File

@ -40,75 +40,78 @@ class Settings(PageObject, SettingsFooter):
@property @property
def username(self): def username(self):
return self.parent.find_element_by_name('user') return self.parent.find_element_by_name('access.user')
@property @property
def password(self): def password(self):
return self.parent.find_element_by_name('password') return self.parent.find_element_by_name('access.password')
@property @property
def show_password(self): def show_password(self):
return self.parent.\ return self.parent.\
find_element_by_xpath('//div[input[@name="password"]]/span') find_element_by_xpath('//div[input[@name="access.password"]]/span')
@property @property
def tenant(self): def tenant(self):
return self.parent.find_element_by_name('tenant') return self.parent.find_element_by_name('access.tenant')
@property @property
def email(self): def email(self):
return self.parent.find_element_by_name('email') return self.parent.find_element_by_name('access.email')
@property @property
def install_savanna(self): def install_savanna(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_CHECKBOX.format('savanna')) find_element_by_xpath(self.XPATH_CHECKBOX.format
('additional_components.sahara'))
@property @property
def install_murano(self): def install_murano(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_CHECKBOX.format('murano')) find_element_by_xpath(self.XPATH_CHECKBOX.format
('additional_components.murano'))
@property @property
def install_ceilometer(self): def install_ceilometer(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_CHECKBOX.format('ceilometer')) find_element_by_xpath(self.XPATH_CHECKBOX.format
('additional_components.ceilometer'))
@property @property
def debug(self): def debug(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_CHECKBOX.format('debug')) find_element_by_xpath(self.XPATH_CHECKBOX.format('common.debug'))
@property @property
def hypervisor_kvm(self): def hypervisor_kvm(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_RADIO.format('libvirt_type', find_element_by_xpath(self.XPATH_RADIO.format
'kvm')) ('common.libvirt_type', 'kvm'))
@property @property
def hypervisor_qemu(self): def hypervisor_qemu(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_RADIO.format('libvirt_type', find_element_by_xpath(self.XPATH_RADIO.format
'qemu')) ('common.libvirt_type', 'qemu'))
@property @property
def assign_ip(self): def assign_ip(self):
return self.parent.\ return self.parent.\
find_element_by_xpath( find_element_by_xpath(
self.XPATH_CHECKBOX.format('auto_assign_floating_ip')) self.XPATH_CHECKBOX.format('common.auto_assign_floating_ip'))
@property @property
def filter_scheduler(self): def filter_scheduler(self):
return self.parent.find_element_by_xpath( return self.parent.find_element_by_xpath(
self.XPATH_RADIO.format( self.XPATH_RADIO.format(
'compute_scheduler_driver', 'common.compute_scheduler_driver',
'nova.scheduler.filter_scheduler.FilterScheduler')) 'nova.scheduler.filter_scheduler.FilterScheduler'))
@property @property
def simple_scheduler(self): def simple_scheduler(self):
return self.parent.find_element_by_xpath( return self.parent.find_element_by_xpath(
self.XPATH_RADIO.format( self.XPATH_RADIO.format(
'compute_scheduler_driver', 'common.compute_scheduler_driver',
'nova.scheduler.simple.SimpleScheduler')) 'nova.scheduler.simple.SimpleScheduler'))
@property @property
@ -126,75 +129,80 @@ class Settings(PageObject, SettingsFooter):
def vlan_splinters_soft(self): def vlan_splinters_soft(self):
return self.parent.\ return self.parent.\
find_element_by_xpath( find_element_by_xpath(
self.XPATH_RADIO.format('vlan_splinters', 'soft')) self.XPATH_RADIO.format('vlan_splinters.vswitch', 'soft'))
@property @property
def vlan_splinters_hard(self): def vlan_splinters_hard(self):
return self.parent.\ return self.parent.\
find_element_by_xpath( find_element_by_xpath(
self.XPATH_RADIO.format('vlan_splinters', 'hard')) self.XPATH_RADIO.format('vlan_splinters.vswitch', 'hard'))
@property @property
def use_cow_images(self): def use_cow_images(self):
return self.parent.\ return self.parent.\
find_element_by_xpath( find_element_by_xpath(
self.XPATH_CHECKBOX.format('use_cow_images')) self.XPATH_CHECKBOX.format('common.use_cow_images'))
@property @property
def start_guests(self): def start_guests(self):
return self.parent.\ return self.parent.\
find_element_by_xpath( find_element_by_xpath(
self.XPATH_CHECKBOX.format('start_guests_on_host_boot')) self.XPATH_CHECKBOX.format('common.start_guests_on_host_boot'))
@property @property
def auth_key(self): def auth_key(self):
return self.parent.find_element_by_name('auth_key') return self.parent.find_element_by_name('common.auth_key')
@property @property
def syslog_server(self): def syslog_server(self):
return self.parent.find_element_by_name('syslog_server') return self.parent.find_element_by_name('syslog.syslog_server')
@property @property
def syslog_port(self): def syslog_port(self):
return self.parent.find_element_by_name('syslog_port') return self.parent.find_element_by_name('syslog.syslog_port')
@property @property
def syslog_udp(self): def syslog_udp(self):
return self.parent.find_element_by_xpath( return self.parent.find_element_by_xpath(
self.XPATH_RADIO.format( self.XPATH_RADIO.format(
'syslog_transport', 'udp')) 'syslog.syslog_transport', 'udp'))
@property @property
def syslog_tcp(self): def syslog_tcp(self):
return self.parent.find_element_by_xpath( return self.parent.find_element_by_xpath(
self.XPATH_RADIO.format( self.XPATH_RADIO.format(
'syslog_transport', 'tcp')) 'syslog.syslog_transport', 'tcp'))
@property @property
def cinder_for_volumes(self): def cinder_for_volumes(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_CHECKBOX.format('volumes_lvm')) find_element_by_xpath(self.XPATH_CHECKBOX.format
('storage.volumes_lvm'))
@property @property
def ceph_for_volumes(self): def ceph_for_volumes(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_CHECKBOX.format('volumes_ceph')) find_element_by_xpath(self.XPATH_CHECKBOX.format
('storage.volumes_ceph'))
@property @property
def ceph_for_images(self): def ceph_for_images(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_CHECKBOX.format('images_ceph')) find_element_by_xpath(self.XPATH_CHECKBOX.format
('storage.images_ceph'))
@property @property
def ceph_ephemeral(self): def ceph_ephemeral(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_CHECKBOX.format('ephemeral_ceph')) find_element_by_xpath(self.XPATH_CHECKBOX.format
('storage.ephemeral_ceph'))
@property @property
def ceph_rados_gw(self): def ceph_rados_gw(self):
return self.parent.\ return self.parent.\
find_element_by_xpath(self.XPATH_CHECKBOX.format('objects_ceph')) find_element_by_xpath(self.XPATH_CHECKBOX.format
('storage.objects_ceph'))
@property @property
def ceph_factor(self): def ceph_factor(self):
return self.parent.find_element_by_name('osd_pool_size') return self.parent.find_element_by_name('storage.osd_pool_size')

View File

@ -427,8 +427,9 @@ class TestBondingInterfaces(BaseTestCase):
Scenario: Scenario:
1. Verify bond and unbond buttons are disabled 1. Verify bond and unbond buttons are disabled
""" """
PageObject.find_element(InterfacesSettings(), 'bond_interfaces') self.assertFalse(PageObject.find_element
self.assertFalse(InterfacesSettings().bond_interfaces.is_enabled()) (InterfacesSettings(), 'bond_interfaces').
is_enabled())
self.assertFalse(InterfacesSettings().unbond_interfaces.is_enabled()) self.assertFalse(InterfacesSettings().unbond_interfaces.is_enabled())
def test_inactive_one_selected(self): def test_inactive_one_selected(self):

View File

@ -6,6 +6,7 @@ from pageobjects.settings import Settings
from pageobjects.tabs import Tabs from pageobjects.tabs import Tabs
from settings import OPENSTACK_CENTOS, OPENSTACK_RELEASE_CENTOS from settings import OPENSTACK_CENTOS, OPENSTACK_RELEASE_CENTOS
from tests.base import BaseTestCase from tests.base import BaseTestCase
from pageobjects.base import PageObject
class TestEnvironment(BaseTestCase): class TestEnvironment(BaseTestCase):
@ -96,9 +97,11 @@ class TestEnvironment(BaseTestCase):
cb.click() cb.click()
with Nodes() as n: with Nodes() as n:
self.assertEqual(n.env_name.text, OPENSTACK_CENTOS) self.assertEqual(PageObject.get_text(n, 'env_name'),
n.info_icon.click() OPENSTACK_CENTOS)
self.assertIn(OPENSTACK_CENTOS, n.env_details.text) PageObject.click_element(n, 'info_icon')
self.assertIn(OPENSTACK_CENTOS, PageObject.get_text
(n, 'env_details'))
self.assertIn('Multi-node with HA', n.env_details.text) self.assertIn('Multi-node with HA', n.env_details.text)
def test_hypervisor_kvm(self): def test_hypervisor_kvm(self):
@ -216,8 +219,6 @@ class TestEnvironment(BaseTestCase):
Tabs().settings.click() Tabs().settings.click()
with Settings() as s: with Settings() as s:
self.assertTrue(s.cinder_for_volumes.
find_element_by_tag_name('input').is_selected())
self.assertTrue(s.ceph_for_volumes. self.assertTrue(s.ceph_for_volumes.
find_element_by_tag_name('input').is_selected()) find_element_by_tag_name('input').is_selected())
self.assertTrue(s.ceph_for_images. self.assertTrue(s.ceph_for_images.