|
@@ -119,6 +119,8 @@ created when you use the find_* methods.
|
|
|
'accept_ssl_certs' - <boolean> - whether SSL certs should be accepted, default is true.
|
|
'accept_ssl_certs' - <boolean> - whether SSL certs should be accepted, default is true.
|
|
|
'auto_close' - <boolean> - whether driver should end session on remote
|
|
'auto_close' - <boolean> - whether driver should end session on remote
|
|
|
server on close.
|
|
server on close.
|
|
|
|
|
+ 'default_finder' - <string> - choose default finder used for find_element*
|
|
|
|
|
+ {class|class_name|css|id|link|link_text|name|partial_link_text|tag_name|xpath}
|
|
|
'extra_capabilities' - HASH of extra capabilities
|
|
'extra_capabilities' - HASH of extra capabilities
|
|
|
'proxy' - HASH - Proxy configuration with the following keys:
|
|
'proxy' - HASH - Proxy configuration with the following keys:
|
|
|
'proxyType' - <string> - REQUIRED, Possible values are:
|
|
'proxyType' - <string> - REQUIRED, Possible values are:
|
|
@@ -164,6 +166,8 @@ created when you use the find_* methods.
|
|
|
);
|
|
);
|
|
|
or
|
|
or
|
|
|
my $driver = Selenium::Remote::Driver->new('proxy' => {'proxyType' => 'manual', 'httpProxy' => 'myproxy.com:1234'});
|
|
my $driver = Selenium::Remote::Driver->new('proxy' => {'proxyType' => 'manual', 'httpProxy' => 'myproxy.com:1234'});
|
|
|
|
|
+ or
|
|
|
|
|
+ my $driver = Selenium::Remote::Driver->new('default_finder' => 'css');
|
|
|
|
|
|
|
|
=cut
|
|
=cut
|
|
|
|
|
|
|
@@ -173,16 +177,17 @@ sub new {
|
|
|
|
|
|
|
|
# Set the defaults if user doesn't send any
|
|
# Set the defaults if user doesn't send any
|
|
|
my $self = {
|
|
my $self = {
|
|
|
- remote_server_addr => delete $args{remote_server_addr} || 'localhost',
|
|
|
|
|
- browser_name => delete $args{browser_name} || 'firefox',
|
|
|
|
|
- platform => delete $args{platform} || 'ANY',
|
|
|
|
|
- port => delete $args{port} || '4444',
|
|
|
|
|
- version => delete $args{version} || '',
|
|
|
|
|
|
|
+ remote_server_addr => delete $args{remote_server_addr} || 'localhost',
|
|
|
|
|
+ browser_name => delete $args{browser_name} || 'firefox',
|
|
|
|
|
+ platform => delete $args{platform} || 'ANY',
|
|
|
|
|
+ port => delete $args{port} || '4444',
|
|
|
|
|
+ version => delete $args{version} || '',
|
|
|
|
|
+ default_finder => FINDERS->{delete $args{default_finder} || 'xpath'},
|
|
|
session_id => undef,
|
|
session_id => undef,
|
|
|
remote_conn => undef,
|
|
remote_conn => undef,
|
|
|
commands => $ress,
|
|
commands => $ress,
|
|
|
auto_close => 1, # by default we will close remote session on DESTROY
|
|
auto_close => 1, # by default we will close remote session on DESTROY
|
|
|
- pid => $$,
|
|
|
|
|
|
|
+ pid => $$
|
|
|
};
|
|
};
|
|
|
bless $self, $class or die "Can't bless $class: $!";
|
|
bless $self, $class or die "Can't bless $class: $!";
|
|
|
|
|
|
|
@@ -1448,7 +1453,7 @@ sub get_page_source {
|
|
|
STRING - Locator scheme to use to search the element, available schemes:
|
|
STRING - Locator scheme to use to search the element, available schemes:
|
|
|
{class, class_name, css, id, link, link_text, partial_link_text,
|
|
{class, class_name, css, id, link, link_text, partial_link_text,
|
|
|
tag_name, name, xpath}
|
|
tag_name, name, xpath}
|
|
|
- Defaults to 'xpath'.
|
|
|
|
|
|
|
+ Defaults to 'xpath' if not configured global during instantiation.
|
|
|
|
|
|
|
|
Output:
|
|
Output:
|
|
|
Selenium::Remote::WebElement - WebElement Object
|
|
Selenium::Remote::WebElement - WebElement Object
|
|
@@ -1463,7 +1468,7 @@ sub find_element {
|
|
|
if ( not defined $query ) {
|
|
if ( not defined $query ) {
|
|
|
croak 'Search string to find element not provided.';
|
|
croak 'Search string to find element not provided.';
|
|
|
}
|
|
}
|
|
|
- my $using = ( defined $method ) ? FINDERS->{$method} : 'xpath';
|
|
|
|
|
|
|
+ my $using = ( defined $method ) ? FINDERS->{$method} : $self->{default_finder};
|
|
|
if (defined $using) {
|
|
if (defined $using) {
|
|
|
my $res = { 'command' => 'findElement' };
|
|
my $res = { 'command' => 'findElement' };
|
|
|
my $params = { 'using' => $using, 'value' => $query };
|
|
my $params = { 'using' => $using, 'value' => $query };
|
|
@@ -1500,7 +1505,7 @@ sub find_element {
|
|
|
STRING - Locator scheme to use to search the element, available schemes:
|
|
STRING - Locator scheme to use to search the element, available schemes:
|
|
|
{class, class_name, css, id, link, link_text, partial_link_text,
|
|
{class, class_name, css, id, link, link_text, partial_link_text,
|
|
|
tag_name, name, xpath}
|
|
tag_name, name, xpath}
|
|
|
- Defaults to 'xpath'.
|
|
|
|
|
|
|
+ Defaults to 'xpath' if not configured global during instantiation.
|
|
|
|
|
|
|
|
Output:
|
|
Output:
|
|
|
ARRAY of Selenium::Remote::WebElement - Array of WebElement Objects
|
|
ARRAY of Selenium::Remote::WebElement - Array of WebElement Objects
|
|
@@ -1515,7 +1520,9 @@ sub find_elements {
|
|
|
if ( not defined $query ) {
|
|
if ( not defined $query ) {
|
|
|
croak 'Search string to find element not provided.';
|
|
croak 'Search string to find element not provided.';
|
|
|
}
|
|
}
|
|
|
- my $using = ( defined $method ) ? FINDERS->{$method} : 'xpath';
|
|
|
|
|
|
|
+
|
|
|
|
|
+ my $using = ( defined $method ) ? FINDERS->{$method} : $self->{default_finder};
|
|
|
|
|
+
|
|
|
if (defined $using) {
|
|
if (defined $using) {
|
|
|
my $res = { 'command' => 'findElements' };
|
|
my $res = { 'command' => 'findElements' };
|
|
|
my $params = { 'using' => $using, 'value' => $query };
|
|
my $params = { 'using' => $using, 'value' => $query };
|
|
@@ -1531,13 +1538,11 @@ sub find_elements {
|
|
|
die $@;
|
|
die $@;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- my $elem_obj_arr = [];
|
|
|
|
|
- my $i = 0;
|
|
|
|
|
|
|
+ my @elem_obj_arr = ();
|
|
|
foreach (@$ret_data) {
|
|
foreach (@$ret_data) {
|
|
|
- $elem_obj_arr->[$i] = new Selenium::Remote::WebElement($_->{ELEMENT}, $self);
|
|
|
|
|
- $i++;
|
|
|
|
|
|
|
+ push(@elem_obj_arr, new Selenium::Remote::WebElement($_->{ELEMENT}, $self));
|
|
|
}
|
|
}
|
|
|
- return wantarray?@{$elem_obj_arr}:$elem_obj_arr;
|
|
|
|
|
|
|
+ return @elem_obj_arr;
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
croak "Bad method, expected - class, class_name, css, id, link,
|
|
croak "Bad method, expected - class, class_name, css, id, link,
|
|
@@ -1564,7 +1569,7 @@ sub find_elements {
|
|
|
STRING - Locator scheme to use to search the element, available schemes:
|
|
STRING - Locator scheme to use to search the element, available schemes:
|
|
|
{class, class_name, css, id, link, link_text, partial_link_text,
|
|
{class, class_name, css, id, link, link_text, partial_link_text,
|
|
|
tag_name, name, xpath}
|
|
tag_name, name, xpath}
|
|
|
- Defaults to 'xpath'.
|
|
|
|
|
|
|
+ Defaults to 'xpath' if not configured global during instantiation.
|
|
|
|
|
|
|
|
Output:
|
|
Output:
|
|
|
Selenium::Remote::WebElement - WebElement Object
|
|
Selenium::Remote::WebElement - WebElement Object
|
|
@@ -1581,7 +1586,7 @@ sub find_child_element {
|
|
|
if ( ( not defined $elem ) || ( not defined $query ) ) {
|
|
if ( ( not defined $elem ) || ( not defined $query ) ) {
|
|
|
croak "Missing parameters";
|
|
croak "Missing parameters";
|
|
|
}
|
|
}
|
|
|
- my $using = ( defined $method ) ? $method : 'xpath';
|
|
|
|
|
|
|
+ my $using = ( defined $method ) ? $method : $self->{default_finder};
|
|
|
if (exists FINDERS->{$using}) {
|
|
if (exists FINDERS->{$using}) {
|
|
|
my $res = { 'command' => 'findChildElement', 'id' => $elem->{id} };
|
|
my $res = { 'command' => 'findChildElement', 'id' => $elem->{id} };
|
|
|
my $params = { 'using' => FINDERS->{$using}, 'value' => $query };
|
|
my $params = { 'using' => FINDERS->{$using}, 'value' => $query };
|
|
@@ -1621,7 +1626,7 @@ sub find_child_element {
|
|
|
STRING - Locator scheme to use to search the element, available schemes:
|
|
STRING - Locator scheme to use to search the element, available schemes:
|
|
|
{class, class_name, css, id, link, link_text, partial_link_text,
|
|
{class, class_name, css, id, link, link_text, partial_link_text,
|
|
|
tag_name, name, xpath}
|
|
tag_name, name, xpath}
|
|
|
- Defaults to 'xpath'.
|
|
|
|
|
|
|
+ Defaults to 'xpath' if not configured global during instantiation.
|
|
|
|
|
|
|
|
Output:
|
|
Output:
|
|
|
ARRAY of Selenium::Remote::WebElement - Array of WebElement Objects.
|
|
ARRAY of Selenium::Remote::WebElement - Array of WebElement Objects.
|
|
@@ -1637,7 +1642,7 @@ sub find_child_elements {
|
|
|
if ( ( not defined $elem ) || ( not defined $query ) ) {
|
|
if ( ( not defined $elem ) || ( not defined $query ) ) {
|
|
|
croak "Missing parameters";
|
|
croak "Missing parameters";
|
|
|
}
|
|
}
|
|
|
- my $using = ( defined $method ) ? $method : 'xpath';
|
|
|
|
|
|
|
+ my $using = ( defined $method ) ? $method : $self->{default_finder};
|
|
|
if (exists FINDERS->{$using}) {
|
|
if (exists FINDERS->{$using}) {
|
|
|
my $res = { 'command' => 'findChildElements', 'id' => $elem->{id} };
|
|
my $res = { 'command' => 'findChildElements', 'id' => $elem->{id} };
|
|
|
my $params = { 'using' => FINDERS->{$using}, 'value' => $query };
|
|
my $params = { 'using' => FINDERS->{$using}, 'value' => $query };
|