File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ const contents = await welcome.getContents();
2525// get all buttons
2626const btns = await welcome .getButtons ();
2727
28+ // get specific button
29+ const btn = await welcome .getButton (" title" );
30+
2831// get paragraphs as strings in a list
2932const text = await welcome .getTextSections ();
3033```
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export class WelcomeContentButton extends AbstractElement {
5454export class WelcomeContentSection extends AbstractElement {
5555 /**
5656 * @param panel The panel containing the welcome content.
57- * @param parent The webelement in which the welcome content is embedded.
57+ * @param parent The webElement in which the welcome content is embedded.
5858 */
5959 constructor ( panel : WebElement , parent : ViewSection ) {
6060 super ( panel , parent ) ;
@@ -77,6 +77,21 @@ export class WelcomeContentSection extends AbstractElement {
7777 ) ;
7878 }
7979
80+ /**
81+ * Returns a specific button from the welcome view that matches the given title.
82+ * @param title The title of the button to search for.
83+ * @returns A `WelcomeContentButton` if found, otherwise `undefined`.
84+ */
85+ public async getButton ( title : string ) : Promise < WelcomeContentButton | undefined > {
86+ const buttons = await this . getButtons ( ) ;
87+ for ( const btn of buttons ) {
88+ if ( ( await btn . getTitle ( ) ) === title ) {
89+ return btn ;
90+ }
91+ }
92+ return undefined ;
93+ }
94+
8095 /** Finds all buttons in the welcome content */
8196 public async getButtons ( ) : Promise < WelcomeContentButton [ ] > {
8297 return ( await this . findElements ( WelcomeContentSection . locators . WelcomeContent . button ) ) . map ( ( elem ) => new WelcomeContentButton ( elem , this ) ) ;
Original file line number Diff line number Diff line change @@ -158,10 +158,10 @@ describe('CustomTreeSection', () => {
158158 describe ( 'WelcomeContentButton' , ( ) => {
159159 it ( 'takeAction executes the command' , async function ( ) {
160160 this . timeout ( 10000 ) ;
161- const buttons = await ( ( await emptyViewSection . findWelcomeContent ( ) ) as WelcomeContentSection ) . getButtons ( ) ;
162- await buttons [ 0 ] . click ( ) ;
163-
164161 await new Promise ( ( res ) => setTimeout ( res , 500 ) ) ;
162+ const button = await ( ( await emptyViewSection . findWelcomeContent ( ) ) as WelcomeContentSection ) . getButton ( 'Add stuff into this View' ) ;
163+ expect ( button ) . to . be . not . be . undefined ;
164+ await button ?. click ( ) ;
165165 expect ( await emptyViewSection . findWelcomeContent ( ) ) . to . equal ( undefined ) ;
166166 } ) ;
167167 } ) ;
You can’t perform that action at this time.
0 commit comments