package jkcs;
import java.util.Properties;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
import java.io.FileInputStream;
public class dqpzwj
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
Properties pzwj = new Properties();
try
{
pzwj.load(new FileInputStream("src/jkcs/config.properties"));
}
catch(Exception e)
{
e.printStackTrace();
}
String pzqd = pzwj.getProperty("qd");
System.out.println(pzqd);
if ("firefox".contentEquals(pzqd))
{
System.setProperty("webdriver.firefox.bin","C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //设置火狐的安装路径,防止系统找不到
FirefoxDriver driver = new FirefoxDriver(); //初始化FireFox浏览器实例,并打开浏览器
driver.get(pzwj.getProperty("url"));
driver.get("https://www.ifeng.com");
driver.quit();
}
}
}
java+selenium+new——读取配置文件——config.properties ——读取配置参数打开浏览器和网址——简单示例...
最新推荐文章于 2024-09-16 15:33:35 发布