Selenium WebDriver Cheat Sheet – Advanced Topic- Firefox Profiling

Posted by

Cheat Sheets are the most effective way to teach things to others. There is an acute shortage of Selenium WebDriver Cheat Sheets. So we have decided to create one yourself for you guys. This cheat sheet for selenium WebDriver provides all the important and commonly used methods, operations and commands for your easy daily access.

Code Example:

  1. package firefoxprofile;
  2. import org.openqa.selenium.WebDriver;
  3. import org.openqa.selenium.firefox.FirefoxDriver;
  4. import org.openqa.selenium.firefox.FirefoxProfile;
  5. import org.openqa.selenium.remote.DesiredCapabilities;
  6. import org.openqa.selenium.remote.RemoteWebDriver;
  7. import com.gargoylesoftware.htmlunit.javascript.host.file.File;
  8. public class firefoxprofile
  9. {
  10.        public static void main(String[] args)
  11.        {
  12.               //Load firefox from non default location
  13.               System.setProperty(“webdriver.firefox.bin”, “mentioned path here”);
  14.               FirefoxProfile fp = new FirefoxProfile();
  15.                /*
  16.                * //load firefox with addons if you want with
  17.                *
  18.                * File file = new File(“path/to/extension.xpi”);
  19.                * fp.addExtension(file);
  20.                *
  21.                */
  22.               //For other setting of browser profile
  23.               DesiredCapabilities dc = new DesiredCapabilities();
  24.               dc.setCapability(FirefoxDriver.PROFILE, fp);
  25.               WebDriver driver = new RemoteWebDriver(dc);
  26.               driver.close();
  27.        }
  28. }

Leave a Reply

Your email address will not be published. Required fields are marked *