File tree Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ import {
4545 DEFAULT_MESSAGE ,
4646 isCamelVersionProductized ,
4747 isVersionNewer ,
48- DEBUG_ITEM_OPERATOR
48+ DEBUG_ITEM_OPERATOR ,
49+ waitUntilViewOpened
4950} from '../utils' ;
5051import waitUntil from 'async-wait-until' ;
5152
@@ -68,15 +69,7 @@ describe('Camel Debugger tests', function () {
6869 await VSBrowser . instance . openResources ( path . resolve ( 'src' , 'ui-test' , 'resources' ) ) ;
6970 console . log ( 'src/ui-test/resources opened' ) ;
7071
71- // workaround: using waitUntil as sometimes the ActivityBar is not ready and then the View is redrawn causing staleElement error
72- await waitUntil ( async ( ) => {
73- try {
74- return await ( await new ActivityBar ( ) . getViewControl ( 'Explorer' ) ) ?. openView ( ) !== undefined ;
75- } catch {
76- return false ;
77- }
78- } , 10000 , 1000 ) ;
79-
72+ waitUntilViewOpened ( 'Explorer' ) ;
8073 console . log ( 'Explorer view opened' ) ;
8174
8275 const section = await new SideBarView ( ) . getContent ( ) . getSection ( 'resources' ) ;
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ import {
3535 disconnectDebugger ,
3636 killTerminal ,
3737 isCamelVersionProductized ,
38+ waitUntilViewOpened ,
3839} from "../utils" ;
3940import { assert } from "chai" ;
4041
@@ -51,7 +52,7 @@ describe("Support pause of Camel debugger", function () {
5152 }
5253 driver = VSBrowser . instance . driver ;
5354 await VSBrowser . instance . openResources ( RESOURCES_DIR ) ;
54- await ( await new ActivityBar ( ) . getViewControl ( 'Explorer' ) ) ?. openView ( ) ;
55+ waitUntilViewOpened ( 'Explorer' ) ;
5556 } ) ;
5657
5758 afterEach ( async function ( ) {
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ import * as path from 'path';
4343import * as fs from 'fs-extra' ;
4444import { ENABLING_CAMEL_DEBUGGER } from './variables' ;
4545import { storageFolder } from "./uitest_runner" ;
46+ import waitUntil from 'async-wait-until' ;
4647
4748// the changes in debug side bar view were presented for new VS Code versions
4849export const DEBUG_ITEM_OPERATOR = ' =' ;
@@ -638,3 +639,18 @@ async function getTerminalText() : Promise<string> {
638639 return await terminal . getText ( ) ;
639640}
640641
642+ /**
643+ * workaround to await (await new ActivityBar().getViewControl(viewName))?.openView()
644+ * using waitUntil as sometimes the ActivityBar is not ready and then the View is redrawn causing staleElement error
645+ * @param viewName
646+ */
647+ export async function waitUntilViewOpened ( viewName :string ) {
648+ await waitUntil ( async ( ) => {
649+ try {
650+ return await ( await new ActivityBar ( ) . getViewControl ( viewName ) ) ?. openView ( ) !== undefined ;
651+ } catch {
652+ return false ;
653+ }
654+ } , 10000 , 1000 ) ;
655+ }
656+
You can’t perform that action at this time.
0 commit comments