java - how to open a link in new tab (chrome) using selenium webdriver? -
system.setproperty("webdriver.chrome.driver", "d:\\softwares\\chromedriver_win32\\chromedriver.exe"); webdriver driver = new chromedriver(); driver.manage().timeouts().implicitlywait(10, timeunit.seconds); driver.manage().window().maximize(); driver.get("https://mail.google.com/"); string selectlinkopeninnewtab = keys.chord(keys.control,keys.return); driver.findelement(by.linktext("www.facebook.com")).sendkeys(selectlinkopeninnewtab);
new tab opening url link not opening
i checked below code , works fine me. found answer here.
driver = new chromedriver(); driver.manage().window().maximize(); baseurl = "http://www.google.co.uk/"; driver.get(baseurl); driver.findelement(by.cssselector("body")).sendkeys(keys.control +"t"); arraylist<string> tabs = new arraylist<string> (driver.getwindowhandles()); driver.switchto().window(tabs.get(1)); //switches new tab driver.get("https://www.facebook.com"); driver.switchto().window(tabs.get(0)); // switch main screen driver.get("https://www.news.google.com");
Comments
Post a Comment