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
• 5,443 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
2 answers

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

You can maximize the window using the ...READ MORE

answered Jun 10, 2021 in Selenium by anonymous

edited Mar 5, 2025 • 18,780 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 10, 2019 in Selenium by Vaishali Walia
• 10,926 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
• 28,140 points

edited Oct 7, 2021 by Sarfaraz • 13,361 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, 2019 in Selenium by Abha
• 28,140 points
• 2,734 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,500 points
• 6,193 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 28, 2018 in Selenium by Meci Matt
• 9,460 points
• 7,893 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP