Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Geting issues in identifying the elsements in webdriver
Fri Feb 17, 2017 4:41 pm by janbaskt

» WebDriver - why not to use a singlton for it?
Fri Feb 17, 2017 4:40 pm by janbaskt

» WebDriver session when using testng annotation to invoke driver instance
Fri Feb 17, 2017 4:39 pm by janbaskt

» Selenium fails to launch Chrome
Fri Feb 17, 2017 4:39 pm by janbaskt

» why do i get this error
Fri Feb 17, 2017 4:38 pm by janbaskt

» Selenium Tutorial
Thu Feb 16, 2017 5:21 pm by Rahul

» When to use Selenium IDE, RC and WebDriver
Mon Feb 13, 2017 2:35 pm by azharuddin

» How to integrate selenium with ZAPI-Zephyr
Sat Feb 11, 2017 2:25 am by gseera002c

» Selenium Webdriver
Sat Feb 04, 2017 6:47 pm by soumyamishrav@gmail.com

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