有没有一种方法可以使用 Selenium 或其他一些 java API 以编程方式创建新的命名 Firefox 配置文件?
Is there a way to create new named Firefox profiles programmatically with Selenium or some other java APIs?
我正在寻找一种以编程方式创建新配置文件的方法,但找不到任何特定的 API 或任何简单的解决方案,例如在特定文件夹中创建特定文件等。有人遇到过这个问题吗?
像这样:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class NewFirefoxProfilesCreator {
public static void main(String[] args) {
int end =100;
int start = 1;
for (int i=start; i<=end; i++) {
try {
Process process = Runtime.getRuntime().exec("\"C:\Program Files (x86)\Mozilla Firefox\firefox.exe\" -no-remote -CreateProfile rnn"+i);
StringBuilder output = new StringBuilder();
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
output.append(line + "\n");
}
int exitVal = process.waitFor();
if (exitVal == 0) {
System.out.println("Success!");
System.out.println(output);
} else {
//abnormal...
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
循环创建 100 个 Firefox 配置文件。
我正在寻找一种以编程方式创建新配置文件的方法,但找不到任何特定的 API 或任何简单的解决方案,例如在特定文件夹中创建特定文件等。有人遇到过这个问题吗?
像这样:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class NewFirefoxProfilesCreator {
public static void main(String[] args) {
int end =100;
int start = 1;
for (int i=start; i<=end; i++) {
try {
Process process = Runtime.getRuntime().exec("\"C:\Program Files (x86)\Mozilla Firefox\firefox.exe\" -no-remote -CreateProfile rnn"+i);
StringBuilder output = new StringBuilder();
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
output.append(line + "\n");
}
int exitVal = process.waitFor();
if (exitVal == 0) {
System.out.println("Success!");
System.out.println(output);
} else {
//abnormal...
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
循环创建 100 个 Firefox 配置文件。