|
@@ -2,6 +2,7 @@ package Selenium::Firefox;
|
|
|
|
|
|
|
|
# ABSTRACT: Use FirefoxDriver without a Selenium server
|
|
# ABSTRACT: Use FirefoxDriver without a Selenium server
|
|
|
use Moo;
|
|
use Moo;
|
|
|
|
|
+use Carp;
|
|
|
use Selenium::Firefox::Binary qw/firefox_path/;
|
|
use Selenium::Firefox::Binary qw/firefox_path/;
|
|
|
use Selenium::CanStartBinary::FindBinary qw/coerce_simple_binary coerce_firefox_binary/;
|
|
use Selenium::CanStartBinary::FindBinary qw/coerce_simple_binary coerce_firefox_binary/;
|
|
|
extends 'Selenium::Remote::Driver';
|
|
extends 'Selenium::Remote::Driver';
|
|
@@ -244,6 +245,65 @@ has 'firefox_binary' => (
|
|
|
builder => 'firefox_path'
|
|
builder => 'firefox_path'
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+=head2 get_context
|
|
|
|
|
+
|
|
|
|
|
+ Description:
|
|
|
|
|
+ Firefox extension: Retrieve browser's scope (chrome or content).
|
|
|
|
|
+ Chrome is a privileged scope where you can access things like the
|
|
|
|
|
+ Firefox UI itself. Content scope is where things like webpages live.
|
|
|
|
|
+
|
|
|
|
|
+ Output:
|
|
|
|
|
+ STRING - context {CHROME|CONTENT}
|
|
|
|
|
+
|
|
|
|
|
+ Usage:
|
|
|
|
|
+ print $firefox_driver->get_context();
|
|
|
|
|
+
|
|
|
|
|
+=cut
|
|
|
|
|
+
|
|
|
|
|
+sub get_context {
|
|
|
|
|
+ my $self = shift;
|
|
|
|
|
+
|
|
|
|
|
+ if ( $self->_is_old_ff ) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ my $res = { 'command' => 'getContext' };
|
|
|
|
|
+ return $self->_execute_command($res);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+=head2 set_context
|
|
|
|
|
+
|
|
|
|
|
+ Description:
|
|
|
|
|
+ Firefox extension: Set browser's scope (chrome or content).
|
|
|
|
|
+ Chrome is a privileged scope where you can access things like the
|
|
|
|
|
+ Firefox UI itself. Content scope is where things like webpages live.
|
|
|
|
|
+
|
|
|
|
|
+ Input:
|
|
|
|
|
+ Required:
|
|
|
|
|
+ <STRING> - context {CHROME|CONTENT}
|
|
|
|
|
+
|
|
|
|
|
+ Usage:
|
|
|
|
|
+ $firefox_driver->set_context( $context );
|
|
|
|
|
+
|
|
|
|
|
+ Output:
|
|
|
|
|
+ BOOLEAN - success or failure
|
|
|
|
|
+
|
|
|
|
|
+=cut
|
|
|
|
|
+
|
|
|
|
|
+sub set_context {
|
|
|
|
|
+ my ( $self, $context ) = @_;
|
|
|
|
|
+
|
|
|
|
|
+ if ( $self->_is_old_ff ) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ( not defined $context ) {
|
|
|
|
|
+ croak "Expecting context";
|
|
|
|
|
+ }
|
|
|
|
|
+ if ( $context !~ m/chrome|content/i ) {
|
|
|
|
|
+ croak "Expecting context value: chrome or content";
|
|
|
|
|
+ }
|
|
|
|
|
+ my $res = { 'command' => 'setContext' };
|
|
|
|
|
+ return $self->_execute_command( $res, { context => $context } );
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
with 'Selenium::CanStartBinary';
|
|
with 'Selenium::CanStartBinary';
|
|
|
|
|
|