Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6763761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:30:53+00:00 2026-05-26T14:30:53+00:00

So I’m using the selenium API, and am using it successfully to test on

  • 0

So I’m using the selenium API, and am using it successfully to test on firefox and chrome. But what would I need to do to run the same unit tests on both browsers automatically. I’ve tried putting the WebDrivers in an ArrayList<WebDriver> drivers object, but the tests don’t run correctly if I do it this way. At the moment there is only one driver in the ArrayList, but it still will not work with just one entry. Here’s some code…

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();
    }
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:30:53+00:00Added an answer on May 26, 2026 at 2:30 pm

    You employed wrong practice.This implementation requires unnecessary looping code within test method. As number of test cases get increase, this kind of practice becomes more painful (think 100s of test cases).

    Use Selenium Grid or utilise QAF formerly ISFW. In Qmetry Automation Framework (QAF) you can set it in configuration file to run against different browsers.
    For example

    <suite name="Test Automation" verbose="0" parallel="tests">
    
        <test name="Test on FF">
          <parameter name="browser" value="InternetExplorerWebDriver" />
        ...
        </test>
        <test name="Test on IE">
          <parameter name="browser" value="firefoxWebDriver" />
        ...
        </test>
    </suit>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I need to clean up various Word 'smart' characters in user input, including but
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.