|
@@ -133,6 +133,10 @@ sub click {
|
|
|
Submit a FORM element. The submit command may also be applied to any element
|
|
Submit a FORM element. The submit command may also be applied to any element
|
|
|
that is a descendant of a FORM element.
|
|
that is a descendant of a FORM element.
|
|
|
|
|
|
|
|
|
|
+ Compatibility:
|
|
|
|
|
+ On webdriver3 enabled servers, this uses a JS shim, which may not submit correctly depending on the element you are attempting to submit.
|
|
|
|
|
+ Try clicking it if possible instead.
|
|
|
|
|
+
|
|
|
Usage:
|
|
Usage:
|
|
|
$elem->submit();
|
|
$elem->submit();
|
|
|
|
|
|
|
@@ -140,7 +144,7 @@ sub click {
|
|
|
|
|
|
|
|
sub submit {
|
|
sub submit {
|
|
|
my ($self) = @_;
|
|
my ($self) = @_;
|
|
|
- return $self->driver->execute_script("return arguments[0].submit();", {'element-6066-11e4-a52e-4f735466cecf'=> $self->{id}} ) if $self->driver->{is_wd3} && !(grep { $self->driver->browser_name eq $_ } qw{chrome MicrosoftEdge});
|
|
|
|
|
|
|
+ return $self->driver->execute_script("if (typeof arguments[0].submit === 'function') { return arguments[0].submit(); }; return 0;", {'element-6066-11e4-a52e-4f735466cecf'=> $self->{id}} ) if $self->driver->{is_wd3} && !(grep { $self->driver->browser_name eq $_ } qw{chrome MicrosoftEdge});
|
|
|
my $res = { 'command' => 'submitElement', 'id' => $self->id };
|
|
my $res = { 'command' => 'submitElement', 'id' => $self->id };
|
|
|
return $self->_execute_command($res);
|
|
return $self->_execute_command($res);
|
|
|
}
|
|
}
|
|
@@ -367,7 +371,9 @@ sub get_element_rect {
|
|
|
determine an element's location for correctly generating native events.
|
|
determine an element's location for correctly generating native events.
|
|
|
|
|
|
|
|
Compatibility:
|
|
Compatibility:
|
|
|
- Not available on WebDriver3 enabled selenium servers.
|
|
|
|
|
|
|
+ On Webdriver3 servers, we have to implement this with a JS shim.
|
|
|
|
|
+ This means in some contexts, you won't get any position returned, as the element isn't considered an element internally.
|
|
|
|
|
+ You may have to go up the element stack to find the element that actually has the bounding box.
|
|
|
|
|
|
|
|
Output:
|
|
Output:
|
|
|
{x:number, y:number} The X and Y coordinates for the element on the page.
|
|
{x:number, y:number} The X and Y coordinates for the element on the page.
|
|
@@ -379,11 +385,15 @@ sub get_element_rect {
|
|
|
|
|
|
|
|
sub get_element_location_in_view {
|
|
sub get_element_location_in_view {
|
|
|
my ($self) = @_;
|
|
my ($self) = @_;
|
|
|
|
|
+ #XXX chrome is dopey here
|
|
|
return $self->driver->execute_script(qq{
|
|
return $self->driver->execute_script(qq{
|
|
|
- arguments[0].scrollIntoView();
|
|
|
|
|
- var pos = arguments[0].getBoundingClientRect();
|
|
|
|
|
- return {y:pos.top,x:pos.left};
|
|
|
|
|
- }, {'element-6066-11e4-a52e-4f735466cecf'=> $self->{id}} ) if $self->driver->{is_wd3} && grep { $self->driver->browser_name eq $_ } ('firefox','internet explorer');
|
|
|
|
|
|
|
+ if (typeof(arguments[0]) !== 'undefined' && arguments[0].nodeType === Node.ELEMENT_NODE) {
|
|
|
|
|
+ arguments[0].scrollIntoView();
|
|
|
|
|
+ var pos = arguments[0].getBoundingClientRect();
|
|
|
|
|
+ return {y:pos.top,x:pos.left};
|
|
|
|
|
+ }
|
|
|
|
|
+ return {};
|
|
|
|
|
+ }, {'element-6066-11e4-a52e-4f735466cecf'=> $self->{id}} ) if $self->driver->{is_wd3} && grep { $self->driver->browser_name eq $_ } ('firefox','internet explorer', 'chrome');
|
|
|
my $res = { 'command' => 'getElementLocationInView', 'id' => $self->id };
|
|
my $res = { 'command' => 'getElementLocationInView', 'id' => $self->id };
|
|
|
return $self->_execute_command($res);
|
|
return $self->_execute_command($res);
|
|
|
}
|
|
}
|