@@ -38,10 +38,14 @@ export default class CodeGraph extends BasePage {
3838 return this . page . locator ( "//button[@role='combobox']" )
3939 }
4040
41- private get selectGraphInComboBox ( ) : ( graph : string ) => Locator {
41+ private get selectGraphInComboBoxByName ( ) : ( graph : string ) => Locator {
4242 return ( graph : string ) => this . page . locator ( `//div[@role='presentation']//div//span[contains(text(), '${ graph } ')]` ) ;
4343 }
4444
45+ private get selectGraphInComboBoxById ( ) : ( graph : string ) => Locator {
46+ return ( graph : string ) => this . page . locator ( `//div[@role='presentation']//div[${ graph } ]` ) ;
47+ }
48+
4549 private get lastElementInChat ( ) : Locator {
4650 return this . page . locator ( "//main[@data-name='main-chat']/*[last()]/span" ) ;
4751 }
@@ -307,10 +311,15 @@ export default class CodeGraph extends BasePage {
307311 }
308312
309313 /* CodeGraph functionality */
310- async selectGraph ( graph : string ) : Promise < void > {
314+ async selectGraph ( graph : string | number ) : Promise < void > {
311315 await this . comboBoxbtn . click ( ) ;
312- await this . selectGraphInComboBox ( graph ) . waitFor ( { state : 'visible' } )
313- await this . selectGraphInComboBox ( graph ) . click ( ) ;
316+ if ( typeof graph === 'number' ) {
317+ await this . selectGraphInComboBoxById ( graph . toString ( ) ) . waitFor ( { state : 'visible' } )
318+ await this . selectGraphInComboBoxById ( graph . toString ( ) ) . click ( ) ;
319+ } else {
320+ await this . selectGraphInComboBoxByName ( graph ) . waitFor ( { state : 'visible' } )
321+ await this . selectGraphInComboBoxByName ( graph ) . click ( ) ;
322+ }
314323 }
315324
316325 async createProject ( url : string ) : Promise < void > {
0 commit comments