Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TE-1703 / Fixed and updated HA UI test #9991

Merged
merged 14 commits into from
Apr 24, 2024
7 changes: 3 additions & 4 deletions tests/bdd/core/test_NAS_T0986.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ def you_should_be_on_the_dashboard(driver):
@then('click on the Accounts on the side menu, click on Users')
def click_on_the_accounts_on_the_side_menu_click_on_users(driver):
"""click on the Accounts on the side menu, click on Users."""
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Accounts"]', 'clickable')
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]', 'clickable')
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
assert wait_on_element(driver, 7, xpaths.sideMenu.accounts, 'clickable')
driver.find_element_by_xpath(xpaths.sideMenu.accounts).click()
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('when the Users page should open, click on the "Add" Button')
Expand Down
6 changes: 3 additions & 3 deletions tests/bdd/core/test_NAS_T1014.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def you_should_be_on_the_dashboard(driver):
@then('click on the Accounts on the side menu, click on Users')
def click_on_the_accounts_on_the_side_menu_click_on_users(driver):
"""click on the Accounts on the side menu, click on Users."""
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
driver.find_element_by_xpath(xpaths.sideMenu.accounts).click()
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]')
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
element = driver.find_element_by_xpath(xpaths.sideMenu.accounts)
class_attribute = element.get_attribute('class')
assert 'open' in class_attribute, class_attribute
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('when the Users page should open, click on the "Add" Button')
Expand Down
6 changes: 3 additions & 3 deletions tests/bdd/core/test_NAS_T1041.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ def on_windows_shares_page_verify_the_smbuser_share_exist(driver):
@then('click on Accounts on the side menu, click on Users')
def click_on_accounts_on_the_side_menu_click_on_users(driver):
"""click on Accounts on the side menu, click on Users."""
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
driver.find_element_by_xpath(xpaths.sideMenu.accounts).click()
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]')
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
element = driver.find_element_by_xpath(xpaths.sideMenu.accounts)
class_attribute = element.get_attribute('class')
assert 'open' in class_attribute, class_attribute
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('on the Users page click Add')
Expand Down
6 changes: 3 additions & 3 deletions tests/bdd/core/test_NAS_T1043.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def you_are_on_the_dashboard(driver):
@then('click on the Accounts on the side menu, click on Users')
def click_on_the_accounts_on_the_side_menu_click_on_users(driver):
"""click on the Accounts on the side menu, click on Users."""
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
driver.find_element_by_xpath(xpaths.sideMenu.accounts).click()
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]')
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
element = driver.find_element_by_xpath(xpaths.sideMenu.accounts)
class_attribute = element.get_attribute('class')
assert 'open' in class_attribute, class_attribute
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('on the Users page, click the foo user right arrow')
Expand Down
6 changes: 3 additions & 3 deletions tests/bdd/core/test_NAS_T1044.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def you_are_on_the_dashboard(driver):
@then('click on the Accounts on the side menu, click on Users')
def click_on_the_accounts_on_the_side_menu_click_on_users(driver):
"""click on the Accounts on the side menu, click on Users."""
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
driver.find_element_by_xpath(xpaths.sideMenu.accounts).click()
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]')
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
element = driver.find_element_by_xpath(xpaths.sideMenu.accounts)
class_attribute = element.get_attribute('class')
assert 'open' in class_attribute, class_attribute
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('on the Users page, click the foo user right arrow')
Expand Down
7 changes: 3 additions & 4 deletions tests/bdd/core/test_NAS_T1060.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ def the_browser_is_open_on_the_truenas_url_and_logged_in(driver, nas_ip, root_pa
def on_the_dashboard_click_on_accounts_on_the_side_menu_click_on_users(driver):
"""on the dashboard, click on Accounts on the side menu, click on Users."""
assert wait_on_element(driver, 10, '//li[contains(.,"Dashboard")]')
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Accounts"]')
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]')
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
assert wait_on_element(driver, 7, xpaths.dashboard.system_information)
rsc.click_on_element(driver, xpaths.sideMenu.accounts)
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('on the Users page should open, click on the Add Button')
Expand Down
11 changes: 1 addition & 10 deletions tests/bdd/ha-bhyve02/test_NAS_T0904.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ def the_service_page_should_open(driver):
@then('press on configure(pencil) SSH')
def press_on_configure_ssh(driver):
"""press on configure(pencil) SSH."""
assert wait_on_element(driver, 5, '//button[@ix-auto="button__S3_Actions"]')
# Scroll to SSH service
element = driver.find_element_by_xpath('//button[@ix-auto="button__S3_Actions"]')
driver.execute_script("arguments[0].scrollIntoView();", element)
time.sleep(1)
assert wait_on_element(driver, 5, '//button[@ix-auto="button__SSH_Actions"]', 'clickable')
driver.find_element_by_xpath('//button[@ix-auto="button__SSH_Actions"]').click()


Expand Down Expand Up @@ -107,11 +103,6 @@ def click_save(driver):
def click_start_automatically_ssh_checkbox_and_enable_the_ssh_service(driver):
"""click Start Automatically SSH checkbox and enable the SSH service."""
assert wait_on_element(driver, 5, '//services')
assert wait_on_element(driver, 5, '//button[@ix-auto="button__S3_Actions"]')
# Scroll to SSH service
element = driver.find_element_by_xpath('//button[@ix-auto="button__S3_Actions"]')
driver.execute_script("arguments[0].scrollIntoView();", element)
time.sleep(1)
assert wait_on_element(driver, 5, '//mat-checkbox[@ix-auto="checkbox__SSH_Start Automatically"]', 'clickable')
value_exist = attribute_value_exist(driver, '//mat-checkbox[@ix-auto="checkbox__SSH_Start Automatically"]', 'class', 'mat-checkbox-checked')
if not value_exist:
Expand Down
8 changes: 4 additions & 4 deletions tests/bdd/ha-bhyve02/test_NAS_T0908.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ def you_should_see_the_dashboard_and_system_information(driver):
@then('Click on the Accounts item in the left side menu')
def click_on_the_accounts_item_in_the_left_side_menu(driver):
"""Click on the Accounts item in the left side menu."""
assert wait_on_element(driver, 10, '//mat-list-item[@ix-auto="option__Accounts"]', 'clickable')
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
assert wait_on_element(driver, 10, xpaths.sideMenu.accounts, 'clickable')
driver.find_element_by_xpath(xpaths.sideMenu.accounts).click()


@then('The Accounts menu should expand down')
def the_accounts_menu_should_expand_down(driver):
"""The Accounts menu should expand down."""
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]', 'clickable')
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
element = driver.find_element_by_xpath(xpaths.sideMenu.accounts)
class_attribute = element.get_attribute('class')
assert 'open' in class_attribute, class_attribute


@then('Click on Users')
def click_on_users(driver):
"""Click on Users."""
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('The Users page should open')
Expand Down
9 changes: 3 additions & 6 deletions tests/bdd/ha-bhyve02/test_NAS_T0909.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,22 @@ def you_should_see_the_dashboard(driver):
@then('Click on the Accounts item in the left side menu')
def click_on_the_accounts_item_in_the_left_side_menu(driver):
"""Click on the Accounts item in the left side menu."""
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
class_attribute = element.get_attribute('class')
if 'open' not in class_attribute:
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.accounts)


@then('The Accounts menu should expand down')
def the_accounts_menu_should_expand_down(driver):
"""The Accounts menu should expand down."""
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]', 'clickable')
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
element = driver.find_element_by_xpath(xpaths.sideMenu.accounts)
class_attribute = element.get_attribute('class')
assert 'open' in class_attribute, class_attribute


@then('Click on Users')
def click_on_users(driver):
"""Click on Users."""
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('The Users page should open')
Expand Down
41 changes: 15 additions & 26 deletions tests/bdd/ha-bhyve02/test_NAS_T0910.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@

import reusableSeleniumCode as rsc
import xpaths
from function import wait_on_element, is_element_present, wait_on_element_disappear
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from function import (
wait_on_element,
is_element_present,
wait_on_element_disappear,
ssh_sudo
)
import time
from pytest_bdd import (
given,
Expand All @@ -24,6 +27,8 @@ def test_edit_user_enable_permit_sudo(driver):
@given(parsers.parse('The browser is open navigate to "{nas_url}"'))
def the_browser_is_open_navigate_to_nas_url(driver, nas_url):
"""The browser is open navigate to "{nas_url}"."""
global nas_host
nas_host = nas_url
if nas_url not in driver.current_url:
driver.get(f"http://{nas_url}/ui/dashboard/")
time.sleep(1)
Expand Down Expand Up @@ -58,25 +63,22 @@ def you_should_see_the_dashboard(driver):
@then('Click on the Accounts item in the left side menu')
def click_on_the_accounts_item_in_the_left_side_menu(driver):
"""Click on the Accounts item in the left side menu."""
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
class_attribute = element.get_attribute('class')
if 'open' not in class_attribute:
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.accounts)


@then('The Accounts menu should expand down')
def the_accounts_menu_should_expand_down(driver):
"""The Accounts menu should expand down."""
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]', 'clickable')
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
element = driver.find_element_by_xpath(xpaths.sideMenu.accounts)
class_attribute = element.get_attribute('class')
assert 'open' in class_attribute, class_attribute


@then('Click on Users')
def click_on_users(driver):
"""Click on Users."""
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
rsc.click_on_element(driver, '//mat-list-item[@ix-auto="option__Users"]')


@then('The Users page should open')
Expand Down Expand Up @@ -150,25 +152,12 @@ def updated_value_should_be_visible(driver):
@then('Open shell and run su user to become that user')
def open_shell_and_run_su_user(driver):
"""Open shell and run su user to become that user."""
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Shell"]', 'clickable')
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Shell"]').click()
assert wait_on_element(driver, 7, '//span[@class="reverse-video terminal-cursor"]')
time.sleep(5)
actions = ActionChains(driver)
actions.send_keys('su ericbsd', Keys.ENTER)
actions.perform()
global sudo_results
cmd = 'ls /var/db/sudo'
sudo_results = ssh_sudo(cmd, nas_host, 'ericbsd', 'testing')


@then('User should be able to use Sudo')
def user_should_be_able_to_use_sudo(driver):
"""User should be able to use Sudo."""
time.sleep(1)
actions = ActionChains(driver)
actions.send_keys('sudo ls /var/db/sudo', Keys.ENTER)
actions.perform()
time.sleep(1)
assert wait_on_element(driver, 7, '//span[contains(.,"Password:")]')
actions.send_keys('testing', Keys.ENTER)
actions.perform()
assert wait_on_element(driver, 7, '//span[contains(.,"lectured")]')
driver.find_element_by_xpath('//span[contains(.,"lectured")]')
assert "lectured" in sudo_results, str(sudo_results)
9 changes: 3 additions & 6 deletions tests/bdd/ha-bhyve02/test_NAS_T0911.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,22 @@ def you_should_see_the_dashboard(driver):
@then('Click on the Accounts item in the left side menu')
def click_on_the_accounts_item_in_the_left_side_menu(driver):
"""Click on the Accounts item in the left side menu."""
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
class_attribute = element.get_attribute('class')
if 'open' not in class_attribute:
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.accounts)


@then('The Accounts menu should expand down')
def the_accounts_menu_should_expand_down(driver):
"""The Accounts menu should expand down."""
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]', 'clickable')
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
element = driver.find_element_by_xpath(xpaths.sideMenu.accounts)
class_attribute = element.get_attribute('class')
assert 'open' in class_attribute, class_attribute


@then('Click on Users')
def click_on_users(driver):
"""Click on Users."""
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('The Users page should open')
Expand Down
9 changes: 3 additions & 6 deletions tests/bdd/ha-bhyve02/test_NAS_T0912.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,22 @@ def you_should_see_the_dashboard(driver):
@then('Click on the Accounts item in the left side menu')
def click_on_the_accounts_item_in_the_left_side_menu(driver):
"""Click on the Accounts item in the left side menu."""
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
class_attribute = element.get_attribute('class')
if 'open' not in class_attribute:
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.accounts)


@then('The Accounts menu should expand down')
def the_accounts_menu_should_expand_down(driver):
"""The Accounts menu should expand down."""
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]', 'clickable')
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
element = driver.find_element_by_xpath(xpaths.sideMenu.accounts)
class_attribute = element.get_attribute('class')
assert 'open' in class_attribute, class_attribute


@then('Click on Users')
def click_on_users(driver):
"""Click on Users."""
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('The Users page should open')
Expand Down
9 changes: 3 additions & 6 deletions tests/bdd/ha-bhyve02/test_NAS_T0913.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,22 @@ def you_should_see_the_dashboard(driver):
@then('Click on the Accounts item in the left side menu')
def click_on_the_accounts_item_in_the_left_side_menu(driver):
"""Click on the Accounts item in the left side menu."""
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
class_attribute = element.get_attribute('class')
if 'open' not in class_attribute:
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.accounts)


@then('The Accounts menu should expand down')
def the_accounts_menu_should_expand_down(driver):
"""The Accounts menu should expand down."""
assert wait_on_element(driver, 7, '//mat-list-item[@ix-auto="option__Users"]', 'clickable')
element = driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Accounts"]')
element = driver.find_element_by_xpath(xpaths.sideMenu.accounts)
class_attribute = element.get_attribute('class')
assert 'open' in class_attribute, class_attribute


@then('Click on Users')
def click_on_users(driver):
"""Click on Users."""
driver.find_element_by_xpath('//mat-list-item[@ix-auto="option__Users"]').click()
rsc.click_on_element(driver, xpaths.sideMenu.users)


@then('The Users page should open')
Expand Down
Loading
Loading