自动化环境配置
IDEA+selenium+火狐浏览器
IDEA安装
官网 https://www.jetbrains.com/idea/
傻瓜式安装
1.create project-Java class
写一段简单的代码,确定IDEA安装是否正确:
public class test {
public static void main(String[] args){
System.out.println(“hello world”);
}
运行显示“hello world”正确
2.安装selenium-server-standalone-3.9.1
File——Project Structure——Libraries——选择selenium-server-standalone-3.9.1——OK
3.下载geckodriver
4.打开百度脚本
public class test {
public static void main(String[] args){
//打开火狐浏览器
System.setProperty(“webdriver.firefox.bin”,“C:\Program Files\Mozilla Firefox\firefox.exe”);
//geckodriver
System.setProperty(“webdriver.gecko.driver”, “D:\geckodriver.exe”);
//初始化
WebDriver driver =new FirefoxDriver();
//打开百度
driver.get(“https://www.baidu.com/”);
driver.quit();
}
}