Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions tests/TestFiles/Modules/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,32 +192,37 @@ public function goto_widget_selection() {

$this->driver->find_element_and_click( '#login-button' );

$window_handles = $this->driver->get_driver()->getWindowHandles();
$this->driver->get_driver()->switchTo()->window( end( $window_handles ) );
$window_handles = $this->driver->get_driver()->getWindowHandles();
$new_window_handle = end( $window_handles );

$this->driver->get_driver()->switchTo()->window( $new_window_handle );

// driver currently on tawk.to OAuth login popout.

// handle currently logged in page.
$allow_id = '#allow';
$allow_button = $this->driver->find_and_check_element( $allow_id );
if ( false === is_null( $allow_button ) ) {
$allow_button->click();
$this->driver->get_driver()->switchTo()->window( reset( $window_handles ) );
$this->driver->wait_for_frame_and_switch( '#tawk-iframe', 10 );
return;
}
// currently logged in page not shown because driver creates new browser instance.

// handle login page.
$this->driver->find_element_and_input( '#email', $this->tawk->username );
$this->driver->find_element_and_input( '#password', $this->tawk->password );
$this->driver->find_element_and_click( 'button[type="submit"]' );

// handle consent page.
$allow_id = '#allow';
$allow_button = $this->driver->find_and_check_element( $allow_id );

if ( false === is_null( $allow_button ) ) {
$allow_button->click();
$start = microtime( true );
while ( ( microtime( true ) - $start ) < 5 ) {
// consent already allowed, window will automatically close.
$current_handles = $this->driver->get_driver()->getWindowHandles();
if ( ! in_array( $new_window_handle, $current_handles, true ) ) {
break;
}

// handle consent page if shown.
try {
$this->driver->find_element_and_click( '#allow' );
break;
} catch ( \Exception $e ) { // phpcs:ignore
// consent button not found, do nothing.
}

usleep( 10000 );
}

// go back to tawk-iframe frame.
Expand Down
2 changes: 1 addition & 1 deletion tests/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:

selenium:
container_name: selenium
image: selenium/standalone-${SELENIUM_BROWSER}:latest
image: selenium/standalone-${SELENIUM_BROWSER}:4.28 # 4.29: intermittent driver session loss when OAuth popout is closed
shm_size: 2g
ports:
- ${SELENIUM_PORT}:4444
Expand Down