Selenium WebDriver Cheat Sheet – Advanced Topic- Firefox/Chrome Profiling

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.

package firefoxprofile;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import com.gargoylesoftware.htmlunit.javascript.host.file.File;
public class firefoxprofile
{
public static void main(String[] args)
{
//Load firefox from non default location
System.setProperty(“webdriver.firefox.bin”, “mentioned path here”);
FirefoxProfile fp = new FirefoxProfile();
/*
* //load firefox with addons if you want with
*
* File file = new File(“path/to/extension.xpi”);
* fp.addExtension(file);
*
*/
DesiredCapabilities dc = new DesiredCapabilities();

dc.setCapability(FirefoxDriver.PROFILE, fp);
WebDriver driver = new RemoteWebDriver(dc);
driver.close();
//For other setting of browser profile of Chrome
ChromeOptions options = new ChromeOptions();
DesiredCapabilities dc01 = new DesiredCapabilities();
dc01.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver01 = new RemoteWebDriver(dc01);
driver01.close();
}
}

Leave a Comment

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

Scroll to Top