Issue
I can open a new window with Selenium WebDriver by using Java and JavaScript. I am using Firefox. The code is as follows:
WebDriver driver = new FirefoxDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("function createDoc(){var w = window.open(); w.document.open(); w.document.write('<h1>Hello World!</h1>'); w.document.close();}; createDoc();");
How can I open a new tab in the same browser by using WebDriver (Selenium 2)?
Solution
Wasim,
cdriver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");
You can use above line to open new tab in a same browser (Works in Firefox)
Answered By - Suresh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.