Time for action – loading the FirefoxDriver - Selenium

We are going to do the basic task of loading the browser and type into the page.

  1. Update the setUp() method to load the Firefox Driver(); driver = new Firefox Driver();

  2. Now we need to find an element. In this section we will find the one with
    the ID nextBid:

    WebElement element = driver.findElement(By.id("nextBid"));
  3. Now we need to type into that element:

  4. Run your test and it should look like the following:

What just happened?

We have just seen how easy it is to run a test with Selenium WebDriver and Firefox. It loaded the browser and then typed into the browser. We can now do everything and anything that we want to the content that is loaded into the browser. Now let's have a look at all the other things that we can do with FirefoxDriver.
Firefox profile preferences

There are times where we need to update the preferences within Firefox. This could be to switch on parts of Firefox that are disabled while they are in development or if you want to get more information from the browser while your tests are running. To do this, we will need to instantiate a Firefox Profile object and then update the settings.

We will then need to pass this object into FirefoxDriver where we instantiate it. This will load the profile with your details you have set. This is like loading about:config in the browser and changing what you need to.

Let's see how we can do this with a code sample.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Selenium Topics