[英]How do you run two instances of firefox using threads in java webdriver
I am a basic java user and currently I am trying to create an automated test case that tests my email functions. 我是一个基本的Java用户,目前我正在尝试创建一个自动测试用例来测试我的电子邮件功能。 So what I have in mind is:
所以我想到的是:
So far the code is this. 到目前为止,代码是这样的。 I am not really sure how to progress from here.
我不太确定如何从这里开始。 More specifically I am not sure how to add the threads in there so that the two instances will run concurrently.
更具体地说,我不确定如何在其中添加线程,以便两个实例可以同时运行。
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);
}
}
}
Why use threads? 为什么要使用线程? Not better prepare two tests?
更好地准备两个测试? Send and receive?
发送和接收? One sends mail - passed ?
一个发送邮件传递? good we can proceed to next one Receiver will wait for an email, checking in interval for example 30 in next XX minutes or so?
好,我们可以继续进行下一个接收者将等待一封电子邮件,例如在接下来的XX分钟左右检查30个间隔吗?
U can run it in TestNG for repeat 3 times? 您可以在TestNG中运行它重复3次吗?
Btw. 顺便说一句。 good post why don't automate gmail :)))
好帖子,为什么不自动化gmail :)))
https://groups.google.com/d/msg/selenium-users/8jR6Fw5ndxU/7peVDuzkNN4J https://groups.google.com/d/msg/selenium-users/8jR6Fw5ndxU/7peVDuzkNN4J
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.