我尝试使用 selenium 驱动程序打开 Firefox 实例,但它显示了一些错误,有时浏览器会打开,但指定的 URL 没有打印到地址栏。
这是我写的代码
包 com.samaritan.automation;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.support.ui.ExpectedCondition;
class CommonFunctions
{
public void click()
{
try
{
String data;
BufferedReader br = new BufferedReader(new FileReader("D:/eRecruiters/_Recruiters - Copy.properties"));
while((data = br.readLine()) != null)
{
String[] strArr = data.split("\t");
String url =new StringBuffer(strArr[1]).append(strArr[0]).toString();
System.out.println(url);
FirefoxDriver driver = new FirefoxDriver();
driver.get(url + "/");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.quit();
}
}
catch(IOException e) {
System.out.println("File not fould !");
}
}
}
有人可以指出我缺少什么吗?我已经安装了最新的 selenium jar 文件,并且我的 machine22.0 上安装了 Firefox 是这个问题吗?或者代码有什么问题吗?