Reputation: 21
i am using Selenium::Remote::Driver module,i want to open the new tab in firefox browser using perl language, can you please suggest me which method i have to use.
**tabsprogram.pl**
use Selenium::Remote::Driver;
use Selenium::Remote::WDKeys;
my $driver = Selenium::Remote::Driver->new();
if(defined $driver)
{
$driver->get("https://www.google.co.in/");
$driver->set_implicit_wait_timeout(40000);
$driver->find_element('body','tag_name')->send_keys(KEYS->{'Ctrl','t'});# the element is find but tab is not clicked
}
But i did not get any error mesage,the new tab is also not opened and driver is quit. please help me....
Upvotes: 2
Views: 845
Reputation: 9075
I did this to get it working
$driver->send_keys_to_active_element(KEYS->{'command_meta'}, 't');
But then I'm on a Mac and Firefox wants Meta-T to open a new tab
If you do
perldoc -l Selenium::Remote::WDKeys
to get the location of the module then look into it it has things like
use constant KEYS => {
'null' => "\N{U+E000}",
'cancel' => "\N{U+E001}",
'help' => "\N{U+E002}",
'backspace' => "\N{U+E003}",
'tab' => "\N{U+E004}",
'clear' => "\N{U+E005}",
'return' => "\N{U+E006}",
'enter' => "\N{U+E007}",
'shift' => "\N{U+E008}",
'control' => "\N{U+E009}",
So you might need to use the word 'control' rather than 'Ctrl' and you can pass 't' without using KEYS->
These are the control keys used as per the link in the module http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value
Upvotes: 3