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,810 points
206 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,400 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,130 points
1,873 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,030 points
474 views
0 votes
1 answer
0 votes
1 answer

How to login a forum using Selenium with Python

You should try to directly log in ...READ MORE

answered Apr 27, 2018 in Selenium by Samarpit
• 5,130 points
155 views
0 votes
1 answer

How to Stop a For-Loop at a special number using Python

driver.find_elements_by_tag_name() returns a list of WebElements. You can use options ...READ MORE

answered May 25, 2018 in Selenium by Samarpit
• 5,130 points
16 views
0 votes
1 answer

How to start with a POST request using Selenium?

No, you cannot do this. But you ...READ MORE

answered Jun 25, 2018 in Selenium by Meci Matt
• 9,400 points
1,083 views
0 votes
1 answer

How to click a span with given text using Selenium Python

If ALL_USA is subject to change, then ...READ MORE

answered Jul 26, 2018 in Selenium by Samarpit
• 5,130 points
1,182 views
0 votes
5 answers
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,400 points
1,685 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.