1

I am new to Ruby language. i want to work with chrome browser using selenium web driver. i am trying to open new tab in chrome browser. but i am unable to get.could you please check below code once.suggest me if anything wrong

require 'selenium-webdriver'
$driver = Selenium::WebDriver.for :chrome
$driver.navigate.to "http://www.google.com/"
$driver.manage.timeouts.implicit_wait = 30

body = $driver.find_element(:tag_name,'body')
body .send_keys(:control,'t')
$driver.navigate.to "http://www.ask.com/"

output: New tab in chrome is not opened,second url also opened in the same page which is already opened with first url.

0

1 Answer 1

0

You should use get method to open URL and also I have corrected your find_element method , Please try below updated code :

require 'selenium-webdriver'

driver = Selenium::WebDriver.for :chrome
driver.get('http://google.com/')
driver.manage.timeouts.implicit_wait = 30

body = driver.find_element(:tag_name => 'body')
body.send_keys(:control, 't')
driver.get('http://www.ask.com/')

Hope above will solve your issue.

Sign up to request clarification or add additional context in comments.

7 Comments

i have done as u suggested, still i am not getting as "new tab is not opened". The above code is working fine in firefox browser but it wont work in chrome,.please help me....
Can you please update your chrome browser? May be version issue.
i am using chrome latest version 40, which version of chrome browser will support selenium 2.44 , please suggest me
Can you tell me where you have put your "chromedriver.exe" ??
path of chromedriver.exe is "C:\Ruby\bin", and this path is set in environment variables
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.