Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Open link in new tab using Chrome driver and C#?

View previous topic View next topic Go down

Open link in new tab using Chrome driver and C#?

Post by gardentools on Fri Feb 17, 2012 11:58 pm

Hi everyone,

I'm having a problem getting Selenium to act as though a link was clicked to open it up in a new tab, rather than in a new window which the link defaults to. I'm using the Chrome driver and C# in visual studio.

I know that in chrome normally if you hold down the control key and then click a link as normal with the left mouse button it will open in a new tab. However I seem to be failing to achieve this. So far I have the code:

driver = new ChromeDriver("C:/");
Actions testAction = new Actions(driver);
testAction.KeyDown(OpenQA.Selenium.Keys.LeftControl);
testAction.Click(driver.FindElement(By.Id("linktoclick")));
testAction.KeyUp(OpenQA.Selenium.Keys.LeftControl);
testAction.Build().Perform();

The logic being I build up a sequence where the left control button is pressed down, then the link is clicked, then the left control is released. This doesn't seem to work though - the link still opens in a new window. Does anyone have an idea why, or a better way to go about doing this?

Thanks in advance.

gardentools

Posts : 1
Join date : 2012-02-17

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum