Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java selenium代码打开并生成多个驱动程序和选项_Java_Selenium - Fatal编程技术网

Java selenium代码打开并生成多个驱动程序和选项

Java selenium代码打开并生成多个驱动程序和选项,java,selenium,Java,Selenium,我需要制作多个WebDriver并立即打开它 我试过下面的代码 public static WebDriver[] driver = new ChromeDriver[99]; public static ChromeOptions[] optionss = new ChromeOptions[99]; public static String[] opt = new String[99]; for(int i=0;i<=99;i++) { opt[i] ="

我需要制作多个WebDriver并立即打开它

我试过下面的代码

public static WebDriver[] driver = new ChromeDriver[99];

public static ChromeOptions[] optionss = new ChromeOptions[99];

public static String[] opt = new String[99];

for(int i=0;i<=99;i++) {
            opt[i] ="user-data-dir=C:\\Users\\dam\\AppData\\Local\\Google\\Chrome\\User Data\\Profile "+i;
            optionss[i].addArguments(opt[i]);
            driver[i] = new ChromeDriver(optionss[i]);
            driver[i].get("https://google.com");
        }
我需要一次打开100个驱动程序,每个驱动程序都会打开完全相同的chrome配置文件

    System.setProperty("webdriver.chrome.driver", System.clearProperty("user.dir")+"\\resources\\chromedriver.exe");
    WebDriver[] drivers = new ChromeDriver[5];// change array size to meet your demand


    for(int i=0;i<5;i++) {// change loop iterations to match array size
        String opt ="user-data-dir=C:\\Users\\dam\\AppData\\Local\\Google\\Chrome\\User Data\\Profile"+i;
        ChromeOptions option = new ChromeOptions();
        option.addArguments(opt);
        ChromeDriver driver = new ChromeDriver(option);
        drivers[i] = driver;
        drivers[i].get("https://google.com");
    }
但是,当for循环执行时,每个浏览器打开之间都有一个延迟


希望这有帮助:goodluck

除了将数组定义为99大小之外,您的问题是什么?它只打开一个驱动程序。。代码不起作用