How to open a new tab using Selenium WebDriver?

后端 未结 29 2498
野的像风
野的像风 2020-11-22 04:40

How to open a new tab in the existing Firefox browser using Selenium WebDriver (a.k.a. Selenium 2)?

29条回答
  •  攒了一身酷
    2020-11-22 05:31

    How to open a new tab using Selenium WebDriver with Java for chrome?

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--disable-extensions");
    driver = new ChromeDriver(options);
    driver.manage().window().maximize();
    driver.navigate().to("https://google.com");     
    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_T);
    robot.keyRelease(KeyEvent.VK_CONTROL);
    robot.keyRelease(KeyEvent.VK_T);
    

    Above code will disable first extensions and using robot class new tab will open.

提交回复
热议问题