When i click on copy link it means url is copied , then open new tab and paste the copied url in new tab using selenium webdriver. Below code is working in windows not in mac. when i used this code in mac system, some java software icon is coming in taskbar. Attached screenshot for your reference.Java software icon in right corner and application screenshotError in console
My Code:
String element=Util.OR_VF_MY_ACCOUNT_PAGE.getProperty("myAccountPageCopyUrlLinkInWishList");
$(element).click();
winHandleBefore= getDriver().getWindowHandle();
Set<String> handles = getDriver().getWindowHandles();
//getDriver().findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_T);
robot.keyRelease(KeyEvent.VK_T);
robot.keyRelease(KeyEvent.VK_CONTROL);
for(String windowHandle : handles)
{
if(!windowHandle.equals(winHandleBefore))
{
getDriver().switchTo().window(windowHandle);
}
}
Util.pause(4);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
Util.pause(4);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
Util.pause(4);
I think its because on a Mac/Unix OS there is no "Control" key. Try to use the "Command" key instead on Mac/unix systems.
Here is a post on how to check which system is operating so you can change from "Ctrl" to "Command" automatically
Edit
With javascript you are able to open new tabs/windows depending on the browser implementation. I have no idea if a new window will be accesible through the same WebDriver instance (and I can't test it out atm). But basically this snippit should work on most Drivers.