File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,18 @@ async function runTutorial () {
3434
3535 await tutorial . waitFor ( 10000 , 'Some time for starting the service' ) ;
3636 await utils . takeScreenshot ( page , screenshotPrefix + 'service_started' ) ;
37+
38+ const entitiesListed = [
39+ "Vein.vtk" ,
40+ "Artery.vtk" ,
41+ "Bones.e" ,
42+ ] ;
43+ for ( const text of entitiesListed ) {
44+ const found = await utils . waitForLabelText ( page , text ) ;
45+ if ( ! found ) {
46+ throw new Error ( `Text "${ text } " not visible on the page within timeout.` ) ;
47+ }
48+ }
3749 }
3850 catch ( err ) {
3951 await tutorial . setTutorialFailed ( ) ;
Original file line number Diff line number Diff line change @@ -634,6 +634,25 @@ async function getButtonsWithText(page, text) {
634634 return buttons ;
635635}
636636
637+ async function waitForLabelText ( page , text , timeout = 10000 ) {
638+ try {
639+ await page . waitForFunction (
640+ ( text ) => {
641+ return [ ...document . body . querySelectorAll ( '*' ) ] . some ( el =>
642+ el . innerText . includes ( text ) &&
643+ ! ! ( el . offsetWidth || el . offsetHeight || el . getClientRects ( ) . length ) // check if element is visible
644+ ) ;
645+ } ,
646+ { timeout } ,
647+ text
648+ ) ;
649+ return true ;
650+ } catch ( err ) {
651+ // WaitForFunction throws if timeout is reached
652+ return false ;
653+ }
654+ }
655+
637656
638657module . exports = {
639658 makeRequest,
@@ -671,4 +690,5 @@ module.exports = {
671690 isElementVisible,
672691 clickLoggerTitle,
673692 getButtonsWithText,
693+ waitForLabelText,
674694}
You can’t perform that action at this time.
0 commit comments