How to open a new tab in the same browser by using Selenium WebDriver with Java?

后端 未结 4 805
后悔当初
后悔当初 2021-01-03 16:14

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 FirefoxDrive         


        
4条回答
  •  半阙折子戏
    2021-01-03 16:39

    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)

提交回复
热议问题