import * as SUT from '../../playwright-fluent' ; import * as path from 'path' ; describe ( 'Playwright Fluent - switchToPreviousTab' , ( ) : void => { let p ; beforeEach ( ( ) : void => { p = new SUT . PlaywrightFluent ( ) ; } ) ; afterEach ( async ( ) : Promise < void > => { await p . close ( ) ; } ) ; test ( 'should be able to switch back to previous tab - chromium' , async ( ) : Promise < void > => { const url = `file:${ path . join ( __dirname , 'switch-to-previous-tab.test.html' ) }` ; const checkMeOut = p . selector ( 'label' ) . withText ( 'Check me out' ) . parent ( ) . find ( 'input' ) ; const storyBookIframe = 'iframe#storybook-preview-iframe' ; await p . withBrowser ( 'chromium' ) . withOptions ( { headless : false } ) . withCursor ( ) . emulateDevice ( 'iPhone 6 landscape' ) . navigateTo ( url ) . click ( p . selector ( 'a[target="_blank"]' ) . withText ( 'open reactstrap form' ) ) . switchToIframe ( storyBookIframe ) . hover ( checkMeOut ) . expectThat ( checkMeOut ) . isUnchecked ( ) . switchBackToPage ( ) . switchToPreviousTab ( ) . expectThat ( checkMeOut ) . isNotVisible ( ) . switchToPreviousTab ( ) . switchToIframe ( storyBookIframe ) . expectThat ( checkMeOut ) . isVisible ( ) ; expect ( p . hasBeenRedirectedToAnotherTab ( ) ) . toBe ( true ) ; expect ( await p . getCurrentUrl ( ) ) . toContain ( 'https://reactstrap.github.io' ) ; } ) ; } ) ;