@@ -16,7 +16,9 @@ export class HostManagementPage extends BasePage {
1616 }
1717
1818 protected async verifyPageLoaded ( ) : Promise < void > {
19- await expect ( this . page . getByRole ( 'heading' , { name : / h o s t m a n a g e m e n t / i } ) ) . toBeVisible ( { timeout : 10000 } ) ;
19+ // Check for either "Host management" heading or "Host setup and management"
20+ const heading = this . page . getByRole ( 'heading' , { name : / h o s t .* m a n a g e m e n t / i } ) . first ( ) ;
21+ await expect ( heading ) . toBeVisible ( { timeout : 10000 } ) ;
2022 this . logger . success ( 'Host management page loaded' ) ;
2123 }
2224
@@ -47,21 +49,33 @@ export class HostManagementPage extends BasePage {
4749 // Wait for host table to load
4850 await this . page . waitForLoadState ( 'networkidle' ) ;
4951
50- // Look for host IDs in the table
51- // Host IDs are typically displayed in a column or as links
52- const hostIdElement = this . page . locator ( '[data-field="aid"], [data-field="device_id"]' ) . first ( )
53- . or ( this . page . locator ( 'td' ) . filter ( { hasText : / ^ [ a - f 0 - 9 ] { 32 } $ / i } ) . first ( ) ) ;
52+ // Wait for the hostname column to appear
53+ await this . page . getByText ( 'Hostname' ) . first ( ) . waitFor ( { state : 'visible' , timeout : 10000 } ) ;
5454
55+ // Look for any text content matching the 32-character hex ID pattern
5556 try {
56- const hostId = await hostIdElement . textContent ( { timeout : 5000 } ) ;
57+ // Use evaluate to search the DOM for text matching host ID pattern
58+ const hostId = await this . page . evaluate ( ( ) => {
59+ const walker = document . createTreeWalker ( document . body , NodeFilter . SHOW_TEXT ) ;
60+ const pattern = / ^ [ a - f 0 - 9 ] { 32 } $ / i;
5761
58- if ( hostId && hostId . trim ( ) ) {
59- this . logger . success ( `Found host ID: ${ hostId . trim ( ) } ` ) ;
60- return hostId . trim ( ) ;
61- } else {
62- this . logger . warn ( 'No host ID found in the table' ) ;
62+ let node ;
63+ while ( node = walker . nextNode ( ) ) {
64+ const text = node . textContent ?. trim ( ) || '' ;
65+ if ( pattern . test ( text ) ) {
66+ return text ;
67+ }
68+ }
6369 return null ;
70+ } ) ;
71+
72+ if ( hostId ) {
73+ this . logger . success ( `Found host ID: ${ hostId } ` ) ;
74+ return hostId ;
6475 }
76+
77+ this . logger . warn ( 'No valid host ID found on page' ) ;
78+ return null ;
6579 } catch ( error ) {
6680 this . logger . warn ( `Failed to find host ID: ${ error . message } ` ) ;
6781 this . logger . info ( 'This may indicate no hosts are available in the CID' ) ;
0 commit comments