在eclipse中新建一个项目baidutest;再在src文件夹中新建一个包com.baidutest.homework;再在包中新建一个java类baidusetting,并设置为静态类;最后在项目中新建一个lib文件夹,将selenium的所有架包拷贝到lib文件夹中,并设置选中项目baidutest,右键选择Bulid Path->Configure Bulid Path,将lib中的所有架包添加到Libraries中。至此selenium包配置完毕。
有什么疑惑可以参照百度经验:eclipse+java添加外部架包
现在要做的是:打开百度页面,点击设置中的搜索设置,修改搜索设置中的选项。代码如下:
package com.baidutest.homework;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By.ById;
import java.util.*;//保证List使用正确
public class baidusetting {
public stati