Skip to content

Commit e6bed62

Browse files
committed
Fix edge case with driver spawns
1 parent 30eb103 commit e6bed62

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Revision history for Selenium-Client
22

3+
1.03 2021-04-12 TEODESIAN
4+
[BUG FIXES]
5+
- Don't clobber $? in destructor
6+
- Use Playwright.pm's more clever DESTROY code
7+
38
1.02 2021-02-10 TEODESIAN
49
[BUG FIXES]
510
- Declare minimum version of perl 5.28

at/sanity.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ foreach my $browser (@browsers) {
9999
is($session->GetPageSource(),"<html><head></head><body>ZIPPY\n</body></html>","Can get page source");
100100
is(exception { $session->Back() }, undef, "Can navigate to the last page visited with back()");
101101

102-
alertify($session) unless $browser eq 'safari';
102+
alertify($session) unless $browser eq 'safari' || $browser eq 'firefox';
103103
is(exception { $session->Forward() }, undef, "Can navigate back to previously visited page with forward()");
104104

105105
$session->Back();
@@ -145,8 +145,8 @@ foreach my $browser (@browsers) {
145145
is($rekt, \%erekt, "Can get window rect");
146146
}
147147
#Frames
148-
my $frame = $session->FindElement( using => 'css selector', value => '#frame' );
149-
is( exception { $session->SwitchToFrame( id => $frame->{elementid} ) }, undef, "Can switch into frame");
148+
#my $frame = $session->FindElement( using => 'css selector', value => '#frame' );
149+
#is( exception { $session->SwitchToFrame( id => $frame->{elementid} ) }, undef, "Can switch into frame");
150150
#XXX the above actually does not do anything, only switching by window.frames index actually works lol
151151
$session->SwitchToFrame( id => 0 );
152152
# Check that the driver yanno *actually did something*

dist.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = Selenium-Client
2-
version = 1.02
2+
version = 1.03
33
author = George S. Baugh <george@troglodyne.net>
44
license = MIT
55
copyright_holder = George S. Baugh

lib/Selenium/Client.pm

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,25 @@ sub DESTROY($self) {
370370
kill $sig, $self->{pid};
371371

372372
print "Issued SIG$sig to $self->{pid}, waiting...\n" if $self->{debug};
373-
return waitpid( $self->{pid}, 0 );
373+
374+
# 0 is always WCONTINUED, 1 is always WNOHANG, and POSIX is an expensive import
375+
# When 0 is returned, the process is still active, so it needs more persuasion
376+
foreach (0..3) {
377+
return unless waitpid( $self->{pid}, 1) == 0;
378+
sleep 1;
379+
}
380+
381+
# Advanced persuasion
382+
print "Forcibly terminating selenium server process...\n" if $self->{debug};
383+
kill('TERM', $self->{pid});
384+
385+
#XXX unfortunately I can't just do a SIGALRM, because blocking system calls can't be intercepted on win32
386+
foreach (0..$self->{timeout}) {
387+
return unless waitpid( $self->{pid}, 1 ) == 0;
388+
sleep 1;
389+
}
390+
warn "Could not shut down selenium server!";
391+
return;
374392
}
375393

376394
sub _is_windows {

0 commit comments

Comments
 (0)