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

fixes for failing selenium node page tests #3835

Draft
wants to merge 3 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions packages/playground/tests/frontend_selenium/pages/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,16 @@ def node_details(self):
nodes.append(details)
return nodes

def setup_config(self, node_id):
for i in range(1, len(self.browser.find_elements(*self.node_table))+1):
if (self.browser.find_element(By.XPATH, f"{self.table_xpath}[{str(i)}]/td[1]").text==str(node_id)):
self.browser.find_element(By.XPATH, f"{self.table_xpath}[{str(i)}]/td[6]/span[1]/i").click()
WebDriverWait(self.browser, 30).until(EC.visibility_of_element_located(self.id_label))

def setup_config(self, node_id):
"""
Prepares the setup configuration for a given node ID.
"""
for i in range(1, len(self.browser.find_elements(*self.node_table)) + 1):
if self.browser.find_element(By.XPATH, f"{self.table_xpath}[{i}]/td[1]").text == str(node_id):
elem = self.browser.find_element(By.XPATH, f"{self.table_xpath}[{i}]/td[6]/span[1]/i")
self.browser.execute_script("arguments[0].scrollIntoView(true);", elem)
WebDriverWait(self.browser, 30).until(EC.element_to_be_clickable(elem)).click()
WebDriverWait(self.browser, 30).until(EC.visibility_of_element_located(self.id_label))
def add_config_input(self, ipv4, gw4, ipv6, gw6, domain):
if(ipv4):
self.browser.find_element(*self.ipv4).send_keys(Keys.CONTROL + "a")
Expand Down Expand Up @@ -221,10 +225,27 @@ def set_fee(self, fee):
def get_fee_button(self):
return self.browser.find_element(*self.set_btn)

def wait_for_button(self, button):
WebDriverWait(self.browser, 30).until(EC.element_to_be_clickable(button))
return button
def wait_for(self, keyword):
"""
Waits for an element with specific text to be visible on the page.
"""
try:
WebDriverWait(self.browser, 60).until(
EC.visibility_of_element_located((By.XPATH, f"//*[contains(text(), '{keyword}')]"))
)
except TimeoutException:
print(f"Timeout waiting for keyword: {keyword}")
raise
return True


def wait_for(self, keyword):
WebDriverWait(self.browser, 30).until(EC.visibility_of_element_located((By.XPATH, "//*[contains(text(), '"+ keyword +"')]")))
return True
def wait_for_button(self, button):
"""
Waits for a button to be clickable.
"""
try:
WebDriverWait(self.browser, 60).until(EC.element_to_be_clickable(button))
except TimeoutException:
print("Timeout waiting for button to be clickable.")
raise
return button
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# Time required for the run (12 cases) is approximately 3 minutes.

def before_test_setup(browser):
"""
Prepares the test environment by initializing required pages and importing the test account.
"""
node_page = NodePage(browser)
grid_proxy = GridProxy(browser)
dashboard_page = DashboardPage(browser)
Expand All @@ -29,14 +32,16 @@ def test_node_page(browser):
- Navigate to the dashboard.
- Login into an account (with node).
- Click on Farm from side menu.
Result: User should be navigated to Farm Nodes page and see all his node.
Result: User should be navigated to Farm Nodes page and see all his nodes.
"""
node_page, grid_proxy = before_test_setup(browser)
nodes = grid_proxy.get_twin_node(str(node_page.twin_id))
for node in nodes:
assert str(node['nodeId']) in browser.page_source




# def test_search_node(browser):
# """
# Test Case: TC1217 - Search node
Expand Down Expand Up @@ -196,21 +201,23 @@ def test_add_config(browser):
"""
node_page, grid_proxy = before_test_setup(browser)
nodes = grid_proxy.get_twin_node(str(node_page.twin_id))
rand_node = random.randint(0,len(nodes)-1)
rand_node = random.randint(0, len(nodes) - 1)
node_id = nodes[rand_node]['nodeId']
old_ipv4 = nodes[rand_node]['publicConfig']['ipv4']
node_page.setup_config(node_id)
new_ipv4 = '125.25.25.25/25'
node_page.wait_for_button(node_page.add_config_input(new_ipv4, '125.25.25.24', '2600:1f13:0d15:95:00::/64', '2600:1f13:0d15:95:00::1', 'tf.grid')).click()
node_page.wait_for_button(
node_page.add_config_input(new_ipv4, '125.25.25.24', '2600:1f13:0d15:95:00::/64', '2600:1f13:0d15:95:00::1', 'tf.grid')
).click()
node_page.wait_for('Public config saved successfully.')
counter = 0
while(old_ipv4 != new_ipv4):
while old_ipv4 != new_ipv4 and counter < 30:
old_ipv4 = grid_proxy.get_node_ipv4(node_id)
counter += 1
if(counter==30):
time.sleep(2)
time.sleep(2)
assert grid_proxy.get_node_ipv4(node_id) == new_ipv4


def test_remove_config(browser):
"""
Test Case: TC1222 - Remove a public config
Expand All @@ -224,20 +231,20 @@ def test_remove_config(browser):
"""
node_page, grid_proxy = before_test_setup(browser)
nodes = grid_proxy.get_twin_node(str(node_page.twin_id))
rand_node = random.randint(0,len(nodes)-1)
rand_node = random.randint(0, len(nodes) - 1)
node_id = nodes[rand_node]['nodeId']
node_page.setup_config(node_id)
node_page.remove_config()
node_page.wait_for('Public config removed successfully.')
counter = 0
ipv4 = grid_proxy.get_node_ipv4(node_id)
while(ipv4 != ''):
while ipv4 != '' and counter < 30:
ipv4 = grid_proxy.get_node_ipv4(node_id)
counter += 1
if(counter==30):
time.sleep(2)
time.sleep(2)
assert grid_proxy.get_node_ipv4(node_id) == ''


def test_additional_fee(browser):
"""
Test Case: TC1750 - Additional Fee
Expand All @@ -251,27 +258,26 @@ def test_additional_fee(browser):
"""
node_page, grid_proxy = before_test_setup(browser)
nodes = grid_proxy.get_twin_node(str(node_page.twin_id))
rand_node = random.randint(0,len(nodes)-1)
rand_node = random.randint(0, len(nodes) - 1)
node_id = nodes[rand_node]['nodeId']
node_page.setup_fee(node_id)
cases = ['-10', '0', '-5', '-0', '-8.84']
for case in cases:
node_page.set_fee(case)
assert node_page.wait_for('Fee must be a 0 or more.')
assert node_page.get_fee_button().is_enabled()==False
assert not node_page.get_fee_button().is_enabled()
cases = [generate_inavalid_gateway(), generate_inavalid_ip(), generate_string(), '*d', '_3']
for case in cases:
node_page.set_fee(case)
assert node_page.wait_for('Fee must be a valid number.')
assert node_page.get_fee_button().is_enabled()==False
assert not node_page.get_fee_button().is_enabled()
fee = grid_proxy.get_node_fee(node_id)
new_fee = valid_amount()
node_page.set_fee(new_fee).click()
node_page.wait_for('Additional fee is set successfully.')
counter = 0
while(fee != new_fee):
while fee != new_fee and counter < 30:
fee = grid_proxy.get_node_fee(node_id)
counter += 1
if(counter==30):
time.sleep(2)
time.sleep(2)
assert grid_proxy.get_node_fee(node_id) == new_fee
Loading