From 02c6dab840afa20b0c6c3e3a8c35b86ef754314a Mon Sep 17 00:00:00 2001 From: Martin Pavlasek Date: Thu, 12 Feb 2015 16:08:22 +0100 Subject: [PATCH] Use IDs in locators instead of CSS when it is possible There were a lot of places that uses CSS_SELECTOR table#someid instead of just ID someid. Closes-Bug: 1353628 Partially implements blueprint: selenium-integration-testing Change-Id: Ic6ac9b425976e60c067fc24e9819374c1a6080c2 --- .../integration_tests/pages/admin/system/flavorspage.py | 2 +- .../test/integration_tests/pages/loginpage.py | 6 +++--- .../project/compute/access_and_security/keypairspage.py | 2 +- .../integration_tests/pages/project/compute/imagespage.py | 2 +- .../integration_tests/pages/project/compute/overviewpage.py | 4 ++-- .../integration_tests/pages/settings/changepasswordpage.py | 3 +-- .../integration_tests/pages/settings/usersettingspage.py | 2 +- openstack_dashboard/test/integration_tests/regions/bars.py | 3 +-- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/openstack_dashboard/test/integration_tests/pages/admin/system/flavorspage.py b/openstack_dashboard/test/integration_tests/pages/admin/system/flavorspage.py index 44fd7a0774..72e08bccdf 100644 --- a/openstack_dashboard/test/integration_tests/pages/admin/system/flavorspage.py +++ b/openstack_dashboard/test/integration_tests/pages/admin/system/flavorspage.py @@ -21,7 +21,7 @@ class FlavorsPage(basepage.BaseNavigationPage): DEFAULT_ID = "auto" FLAVORS_TABLE_NAME_COLUMN_INDEX = 0 - _flavors_table_locator = (by.By.CSS_SELECTOR, 'table#flavors') + _flavors_table_locator = (by.By.ID, 'flavors') FLAVORS_TABLE_ACTIONS = ("create_flavor", "delete_flavors") FLAVORS_TABLE_ROW_ACTIONS = { diff --git a/openstack_dashboard/test/integration_tests/pages/loginpage.py b/openstack_dashboard/test/integration_tests/pages/loginpage.py index 93ea18ab21..1630bb73f8 100644 --- a/openstack_dashboard/test/integration_tests/pages/loginpage.py +++ b/openstack_dashboard/test/integration_tests/pages/loginpage.py @@ -21,11 +21,11 @@ from openstack_dashboard.test.integration_tests.pages.project.compute import \ class LoginPage(pageobject.PageObject): - _login_username_field_locator = (by.By.CSS_SELECTOR, '#id_username') - _login_password_field_locator = (by.By.CSS_SELECTOR, '#id_password') + _login_username_field_locator = (by.By.ID, 'id_username') + _login_password_field_locator = (by.By.ID, 'id_password') _login_submit_button_locator = (by.By.CSS_SELECTOR, 'div.modal-footer button.btn') - _login_logout_reason_locator = (by.By.CSS_SELECTOR, '#logout_reason') + _login_logout_reason_locator = (by.By.ID, 'logout_reason') def __init__(self, driver, conf): super(LoginPage, self).__init__(driver, conf) diff --git a/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/keypairspage.py b/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/keypairspage.py index f04ceefad3..47ce935fee 100644 --- a/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/keypairspage.py +++ b/openstack_dashboard/test/integration_tests/pages/project/compute/access_and_security/keypairspage.py @@ -22,7 +22,7 @@ from openstack_dashboard.test.integration_tests.regions import tables class KeypairsPage(basepage.BaseNavigationPage): - _key_pairs_table_locator = (by.By.CSS_SELECTOR, 'table#keypairs') + _key_pairs_table_locator = (by.By.ID, 'keypairs') KEY_PAIRS_TABLE_ACTIONS = ("create_key_pair", "import_key_pair", "delete_key_pair") diff --git a/openstack_dashboard/test/integration_tests/pages/project/compute/imagespage.py b/openstack_dashboard/test/integration_tests/pages/project/compute/imagespage.py index c6691e2d55..3fdcaa5151 100644 --- a/openstack_dashboard/test/integration_tests/pages/project/compute/imagespage.py +++ b/openstack_dashboard/test/integration_tests/pages/project/compute/imagespage.py @@ -26,7 +26,7 @@ class ImagesPage(basepage.BaseNavigationPage): IMAGES_TABLE_NAME_COLUMN_INDEX = 0 IMAGES_TABLE_STATUS_COLUMN_INDEX = 2 - _images_table_locator = (by.By.CSS_SELECTOR, 'table#images') + _images_table_locator = (by.By.ID, 'images') IMAGES_TABLE_ACTIONS = ("create_image", "delete_images") IMAGES_TABLE_ROW_ACTIONS = { diff --git a/openstack_dashboard/test/integration_tests/pages/project/compute/overviewpage.py b/openstack_dashboard/test/integration_tests/pages/project/compute/overviewpage.py index 841fb096a2..7e01f8586b 100644 --- a/openstack_dashboard/test/integration_tests/pages/project/compute/overviewpage.py +++ b/openstack_dashboard/test/integration_tests/pages/project/compute/overviewpage.py @@ -17,8 +17,8 @@ from openstack_dashboard.test.integration_tests.regions import tables class OverviewPage(basepage.BaseNavigationPage): - _usage_table_locator = (by.By.CSS_SELECTOR, 'table#project_usage') - _date_form_locator = (by.By.CSS_SELECTOR, 'form#date_form') + _usage_table_locator = (by.By.ID, 'project_usage') + _date_form_locator = (by.By.ID, 'date_form') USAGE_TABLE_ACTIONS = ("download_csv",) diff --git a/openstack_dashboard/test/integration_tests/pages/settings/changepasswordpage.py b/openstack_dashboard/test/integration_tests/pages/settings/changepasswordpage.py index 2652877780..528b167d3f 100644 --- a/openstack_dashboard/test/integration_tests/pages/settings/changepasswordpage.py +++ b/openstack_dashboard/test/integration_tests/pages/settings/changepasswordpage.py @@ -18,8 +18,7 @@ from openstack_dashboard.test.integration_tests.regions import forms class ChangepasswordPage(basepage.BaseNavigationPage): - _password_form_locator = (by.By.CSS_SELECTOR, - 'div#change_password_modal') + _password_form_locator = (by.By.ID, 'change_password_modal') CHANGE_PASSWORD_FORM_FIELDS = ("current_password", "new_password", "confirm_new_password") diff --git a/openstack_dashboard/test/integration_tests/pages/settings/usersettingspage.py b/openstack_dashboard/test/integration_tests/pages/settings/usersettingspage.py index dbbf89bfd3..0b85b03233 100644 --- a/openstack_dashboard/test/integration_tests/pages/settings/usersettingspage.py +++ b/openstack_dashboard/test/integration_tests/pages/settings/usersettingspage.py @@ -30,7 +30,7 @@ class UsersettingsPage(basepage.BaseNavigationPage): SETTINGS_FORM_FIELDS = ("language", "timezone", "pagesize") - _settings_form_locator = (by.By.CSS_SELECTOR, 'div#user_settings_modal') + _settings_form_locator = (by.By.ID, 'user_settings_modal') _change_password_tab_locator = (by.By.CSS_SELECTOR, 'a[href*="/settings/password/"]') diff --git a/openstack_dashboard/test/integration_tests/regions/bars.py b/openstack_dashboard/test/integration_tests/regions/bars.py index e15f0c729e..c4b96cc9cd 100644 --- a/openstack_dashboard/test/integration_tests/regions/bars.py +++ b/openstack_dashboard/test/integration_tests/regions/bars.py @@ -17,8 +17,7 @@ from openstack_dashboard.test.integration_tests.regions import menus class TopBarRegion(baseregion.BaseRegion): - _user_dropdown_menu_locator = (by.By.CSS_SELECTOR, - 'div#profile_editor_switcher') + _user_dropdown_menu_locator = (by.By.ID, 'profile_editor_switcher') _openstack_brand_locator = (by.By.CSS_SELECTOR, 'a[href*="/home/"]') @property