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
498 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,420 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
4,191 views
0 votes
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 in Selenium by Vaishali Walia
231 views
0 votes
2 answers
+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 in Selenium by Abha
• 27,180 points
164 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,110 points
1,075 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,420 points
2,368 views