firefox.setEnvironmentProperty("DISPLAY", ":" + DISPLAY_NUMBER); WebDriver driver = new FirefoxDriver(firefox, null); driver.get(URL);
FirefoxBinary ffox = new FirefoxBinary(firefoxPath); ffox.setEnvironmentProperty("DISPLAY", ":20"); driver = new FirefoxDriver(ffox, null);
private WebDriver driver = null; public void openHeadless() throws Exception { FirefoxBinary binary = new FirefoxBinary(new File("/usr/local/bin/firefox")); binary.setEnvironmentProperty("DISPLAY",System.getProperty("lmportal.xvfb.id",":99")); driver = new FirefoxDriver(binary,null); }
String Xport = System.getProperty("lmportal.xvfb.id", ":1"); final File firefoxPath = new File(System.getProperty("lmportal.deploy.firefox.path", "/usr/bin/firefox")); FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath); firefoxBinary.setEnvironmentProperty("DISPLAY", Xport);
FirefoxBinary binary = new FirefoxBinary(new File("your/firefox/path")); binary.setEnvironmentProperty("DISPLAY",System.getProperty("lmportal.xvfb.id",":99")); WebDriver webDriver = new FirefoxDriver(binary,null);
public void startProfile(FirefoxProfile profile, String... commandLineFlags) throws IOException { setEnvironmentProperty("XRE_PROFILE_PATH", profile.getProfileDir().getAbsolutePath()); setEnvironmentProperty("MOZ_NO_REMOTE", "1"); List<String> commands = new ArrayList<String>(); commands.add(executable.getPath()); commands.add("--verbose"); commands.addAll(Arrays.asList(commandLineFlags)); ProcessBuilder builder = new ProcessBuilder(commands); builder.redirectErrorStream(); builder.environment().putAll(extraEnv); executable.setLibraryPath(builder, extraEnv); process = builder.start(); }
@Override protected void decorateFirefoxBinary(FirefoxBinary binary) { super.decorateFirefoxBinary(binary); String displayID = displayIdPool.get(); displayScreenId.set(displayID); binary.setEnvironmentProperty("DISPLAY", displayID); System.out.println(new StringBuffer("Displays used=").append(++refCt).toString()); }
public class ApptestData{ public WebDriver driver; public WebDriverWait wait; public ApptestData() throws Exception { File firefoxPath = new File(System.getProperty("lmportal.deploy.firefox.path", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe")); FirefoxBinary ffox = new FirefoxBinary(firefoxPath); ffox.setEnvironmentProperty("DISPLAY", ":20"); driver = new FirefoxDriver(ffox, null); wait = new WebDriverWait(driver, timeoutInSeconds ); Object[][] data = new Object[1][2]; data[0][0] = driver; data[0][1] = wait; twoUsersSignUp(data); return data; } }
FirefoxBinary ffox = new FirefoxBinary(firefoxPath); ffox.setEnvironmentProperty("DISPLAY", ":20"); DesiredCapabilities dc =new DesiredCapabilities(); dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,UnexpectedAlertBehaviour.ACCEPT); driver = new FirefoxDriver(ffox, null, dc);
firefox.setEnvironmentProperty("DISPLAY", ":" + DISPLAY_NUMBER); WebDriver driver = new FirefoxDriver(firefox, null); driver.get(URL);
@Override public WebDriver create(Capabilities capabilities, Properties properties) { final File firefoxPath = new File(properties.getProperty(ConfigKeys.WEBDRIVER_FIREFOX_BIN)); FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath); firefoxBinary.setEnvironmentProperty("DISPLAY", properties.getProperty(ConfigKeys.WEBDRIVER_XVFB_ID)); FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities).setBinary(firefoxBinary); return new FirefoxDriver(firefoxOptions); } };
public abstract class AbstractAppTest { public WebDriver driver; public WebDriverWait wait; @DataProvider(name = "dataProvider") public Object[][] setUp() throws Exception { File firefoxPath = new File(System.getProperty("lmportal.deploy.firefox.path", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe")); FirefoxBinary ffox = new FirefoxBinary(firefoxPath); ffox.setEnvironmentProperty("DISPLAY", ":20"); driver = new FirefoxDriver(ffox, null); wait = new WebDriverWait(driver, timeoutInSeconds ); Object[][] data = new Object[1][2]; data[0][0] = driver; data[0][1] = wait; twoUsersSignUp(data); return data; } public abstract void twoUsersSignUp(@Optional Object[][] data) throws InterruptedException; } public class Apptest extends AbstractAppTest { public void twoUsersSignUp(@Optional Object[][] data) throws InterruptedException { ... } } public class AppTest2 extends AbstractAppTest { public void twoUsersSignUp(@Optional Object[][] data) throws InterruptedException { ... } }
@Override public WebDriver create(Capabilities capabilities, Properties properties) { final File firefoxPath = new File(properties.getProperty(ConfigKeys.WEBDRIVER_FIREFOX_BIN)); FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath); firefoxBinary.setEnvironmentProperty("DISPLAY", properties.getProperty(ConfigKeys.WEBDRIVER_XVFB_ID)); FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities).setBinary(firefoxBinary); return new FirefoxDriver(firefoxOptions); } };