3

I have existing Firefox session with appropriate login data to interesting site. Now I want to use it with Selenium and Perl. I am using this code:

my $driver = Selenium::Remote::Driver->new;
$driver->get("http://www.google.com");
$driver->find_element('q','name')->send_keys("Hello WebDriver!");
print $driver->get_title() . "\n";

But this code opens new blank session of Firefox. How can I use my existing session with already set up cookies?

raina77ow
  • 103,633
  • 15
  • 192
  • 229
John Smith
  • 31
  • 2

2 Answers2

1

You want to specify a Firefox profile to use.

In Java, it'd be something like this...

ProfilesIni profile = new ProfilesIni();
FirefoxProfile firefoxProfile = profile.getProfile("Default"); // might need to switch this around depending on what it actually is named.
WebDriver driver = new FirefoxDriver(firefoxProfile);

(credit to this answer for the pseudo-code)

Community
  • 1
  • 1
ddavison
  • 28,221
  • 15
  • 85
  • 110
0

I think you can try with this option in perl driver.

my $handles = $driver->get_window_handles;
   $driver->switch_to_window($handles->[1]);
   $driver->close;
   $driver->switch_to_window($handles->[0]);

I didn't use it, but may be it will help you!

For more information, please refer to this site. https://metacpan.org/pod/Selenium::Remote::Driver

AdamMc331
  • 16,492
  • 10
  • 71
  • 133