How to I switch to a new window for links with “blank” targets using Capybara?

0 votes
When I am clicking on "click_link" a link with target ="_blank", it the focus on the current window.

I want to either be able to switch to the new window or to ignore the _blank attribute, I want it to navigate it to the page indicated by the link so that I can make sure that it is the right page.

I am using the web-kit and selenium drivers.

Kindly help me out with this
Jul 11, 2018 in Selenium by QueenBee
• 1,820 points
781 views

1 answer to this question.

0 votes

Capybara 2.3 includes the new window management API. 

You can use it as shown below:

new_window = window_opened_by {click_link 'Something'}
within_window new_window do
  # code #
end 
answered Jul 11, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

0 votes
1 answer

How to open a browser window in full screen using Selenium WebDriver with C#

Simply Use this: driver.Manage().Window.Maximize(); READ MORE

answered Jun 7, 2018 in Selenium by Samarpit
• 5,870 points
6,336 views
+1 vote
1 answer
0 votes
1 answer

How to apply wait for new window using Selenium WebDriver?

As sometimes during web automation, when you ...READ MORE

answered Jul 9, 2019 in Selenium by Vaishali Walia
1,236 views
0 votes
2 answers

How to open a new tab in existing browser window using Javascript Executor?

Hi Meenal, you can use executeScript() method ...READ MORE

answered Jul 22, 2019 in Selenium by Abha
• 27,800 points
1,852 views
+1 vote
1 answer

How to handle a combobox which when clicked open in new window with list of items(to be clicked) in selenium java ?

@Pavithra, you can try using following commands ...READ MORE

answered Oct 29, 2019 in Selenium by Abha
• 27,800 points
242 views
0 votes
1 answer

I tried to open a new website when a new tab is opened using Selenium Webdriver

Try this code: ArrayList<String> tabs = new ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,510 points
1,461 views
0 votes
1 answer
0 votes
1 answer

Is it possible for a website to detect that we are using Selenium with ChromeDriver

Selenium tests for pre-defined javascript variables which ...READ MORE

answered Apr 27, 2018 in Selenium by Meci Matt
• 9,460 points
2,987 views