Skip to content

Commit

Permalink
Fix #87: implement is_hidden in WebElement.pm
Browse files Browse the repository at this point in the history
  • Loading branch information
gempesaw committed Jul 16, 2014
1 parent de233ba commit a3e23f1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
18 changes: 18 additions & 0 deletions lib/Selenium/Remote/WebElement.pm
Expand Up @@ -324,6 +324,24 @@ sub is_displayed {
return $self->_execute_command($res);
}

=head2 is_hidden
Description:
Determine if an element is currently hidden.
Output:
BOOLEAN - Whether the element is hidden.
Usage:
$elem->is_hidden();
=cut

sub is_hidden {
my ($self) = @_;
return ! $self->is_displayed();
}

=head2 drag
Description:
Expand Down
12 changes: 11 additions & 1 deletion t/02-webelement.t
Expand Up @@ -111,7 +111,17 @@ IMAGES: {
is($ret->{'x'}, ($x+200), 'Moved to new x coord');
is($ret->{'y'}, ($y+200), 'Moved to new y coord');
}
;
}

VISIBILITY: {
$driver->get("$website/index.html");
$elem = $driver->find_element('displayed', 'id');
ok($elem->is_displayed(), 'Elements are displayed by default.');
ok(!$elem->is_hidden(), 'Elements are not hidden by default.');

$elem = $driver->find_element('hidden', 'id');
ok(!$elem->is_displayed(), 'Hidden elements are not displayed.');
ok($elem->is_hidden(), 'Hidden elements are hidden.');
}

QUIT: {
Expand Down
7 changes: 6 additions & 1 deletion t/www/index.html
Expand Up @@ -64,5 +64,10 @@ <h1>Heading</h1>
<div id="containsSomeDiv">
<div name="someDiv">Nested</div>
</div>

<div id="visibility">
<span id="displayed">I am displayed.</span>
<span id="hidden" style="display: none;">I am hidden.</span>
</div>
</body>
</html>
</html>

0 comments on commit a3e23f1

Please sign in to comment.