因此,使用 se二氧化物,并且正在成功地利用它来测试火f和hr。 但是,我需要做的是自动对这两个浏览器进行同样的单位测试。 I ve试图将网络驱动器置于ArrayList<Web/63/7r>司机代码>标的栏目中,但如果我这样做,则试卷没有正确操作。 目前,只有一名司机在ArrayList,但该驾驶员不会只工作一次。 这里的一些法典......
package testsuites;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class BingTests extends BaseTestSuite{
//private WebDriver fireFoxDriver;
private WebDriver chromeDriver;
private WebDriver fireFoxDriver;
private ArrayList<WebDriver> drivers;
@Before
public void setUp() throws Exception {
fireFoxDriver = new FirefoxDriver();
fireFoxDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
drivers.add(fireFoxDriver);
}
@Test
public void testGoogle(){
for(WebDriver driver: drivers){
driver.get("http://www.bing.com");
driver.findElement(By.id("sb_form_q")).clear();
driver.findElement(By.id("sb_form_q")).sendKeys("Selenium IDE");
driver.findElement(By.id("sb_form_go")).click();
driver.findElement(By.xpath("//ul[@id= wg0 ]/li[2]/div/div/h3/a/strong")).click();
WebElement elem = driver.findElement(By.id("mainContent"));
assertTrue(elem.getText().contains("Selenium News"));
}
}
@Test
public void isWikiContentCorrect(){
for(WebDriver driver: drivers){
driver.get("http://www.bing.com");
driver.findElement(By.id("sb_form_q")).clear();
driver.findElement(By.id("sb_form_q")).sendKeys("Saturn");
driver.findElement(By.id("sb_form_go")).click();
driver.findElement(By.linkText("Saturn - Wikipedia, the free encyclopedia")).click();
driver.findElement(By.cssSelector("li.toclevel-1.tocsection-9 > a > span.toctext")).click();
assertTrue(driver.getPageSource().contains("53 of which"));
}
}
@Test
public void isWikiTitleCorrect(){
for(WebDriver driver: drivers){
driver.get("http://www.bing.com");
driver.findElement(By.id("sb_form_q")).clear();
driver.findElement(By.id("sb_form_q")).sendKeys("Saturn");
driver.findElement(By.id("sb_form_go")).click();
driver.findElement(By.linkText("Saturn - Wikipedia, the free encyclopedia")).click();
assertEquals("Saturn - Wikipedia, the free encyclopedia", driver.getTitle());
}
}
@Test
public void testDropDownWithSelenium(){
for(WebDriver driver: drivers){
driver.get("http://www.bing.com");
driver.findElement(By.id("sb_form_q")).clear();
driver.findElement(By.id("sb_form_q")).sendKeys("Neptunes moon");
driver.findElement(By.partialLinkText("moons and rings")).click();
driver.findElement(By.linkText("Neptune (planet) :: Neptune s moons and rings -- Britannica Online ...")).click();
List<WebElement> elems = driver.findElements(By.tagName("Input"));
for(WebElement elem: elems){
System.out.println(elem.getText());
}
}
}
@After
public void tearDown() throws Exception {
for(WebDriver driver: drivers){
driver.close();
}
}
}