package baidu;
import java.util.regex.Pattern;
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.testng.annotations.*;
import static org.testng.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.support.ui.Select;
public class WebTours {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@BeforeClass(alwaysRun = true)
public void setUp() throws Exception {
// driver = new FirefoxDriver();
baseUrl = "http://127.0.0.1:1080";
/**
* 遇到一个问题: 会在浏览器最上方弹出“允许.....”对话框,如果不点击运行,则无法往下运行, 每次都需要手动点击;
* 在电脑搜索栏中输入:%APPDATA%\Mozilla\Firefox\Profiles\
* 搜索出具体位置, 添加如下代码,先加入网站为安全网站,加入之后使用下面的代码,是从加入安全网站的浏览器中读取,这样就不需要每次都点击允许;
*/
String firefoxProfileDir = "C:\\Users\\dell\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\9fxyphvs.default";
FirefoxProfile profile = new FirefoxProfile(new File(firefoxProfileDir));
driver = new FirefoxDriver(profile);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testWebTours() throws Exception {
driver.get(baseUr
import java.util.regex.Pattern;
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.testng.annotations.*;
import static org.testng.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.support.ui.Select;
public class WebTours {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@BeforeClass(alwaysRun = true)
public void setUp() throws Exception {
// driver = new FirefoxDriver();
baseUrl = "http://127.0.0.1:1080";
/**
* 遇到一个问题: 会在浏览器最上方弹出“允许.....”对话框,如果不点击运行,则无法往下运行, 每次都需要手动点击;
* 在电脑搜索栏中输入:%APPDATA%\Mozilla\Firefox\Profiles\
* 搜索出具体位置, 添加如下代码,先加入网站为安全网站,加入之后使用下面的代码,是从加入安全网站的浏览器中读取,这样就不需要每次都点击允许;
*/
String firefoxProfileDir = "C:\\Users\\dell\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\9fxyphvs.default";
FirefoxProfile profile = new FirefoxProfile(new File(firefoxProfileDir));
driver = new FirefoxDriver(profile);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testWebTours() throws Exception {
driver.get(baseUr