![](/img/trans.png)
[英]How do I set a proxy for firefox using Selenium webdriver with Java?
[英]How do you run two instances of firefox using threads in java webdriver
我是一個基本的Java用戶,目前我正在嘗試創建一個自動測試用例來測試我的電子郵件功能。 所以我想到的是:
到目前為止,代碼是這樣的。 我不太確定如何從這里開始。 更具體地說,我不確定如何在其中添加線程,以便兩個實例可以同時運行。
import static org.junit.Assert.fail;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
public class multi_test {
public WebDriver driver1;
protected WebDriver driver2;
public String baseUrl1;
public String baseUrl2;
protected StringBuffer verificationErrors = new StringBuffer();
public class setup1 implements Runnable{
public void run(){
driver1.get(baseUrl1);
}
}
public class setup2 implements Runnable{
public void run(){
driver2.get(baseUrl2);
}
}
@Before
public void setUp() throws Exception {
driver1 = new FirefoxDriver();
baseUrl1 = "http://www.yahoo.com";
driver1.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
System.out.println(driver1);
driver2 = new FirefoxDriver();
baseUrl2 = "https://google.com";
driver2.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testing1() throws Exception {
driver1.get(baseUrl1);
}
@After
public void tearDown() throws Exception {
//driver1.quit();
//driver2.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
}
為什么要使用線程? 更好地准備兩個測試? 發送和接收? 一個發送郵件傳遞? 好,我們可以繼續進行下一個接收者將等待一封電子郵件,例如在接下來的XX分鍾左右檢查30個間隔嗎?
您可以在TestNG中運行它重復3次嗎?
順便說一句。 好帖子,為什么不自動化gmail :)))
https://groups.google.com/d/msg/selenium-users/8jR6Fw5ndxU/7peVDuzkNN4J
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.