public static WebDriver getFirefoxDriver() throws Exception { baseDir = new File(".").getPath(); System.out.println("******** " + baseDir); String path = "src/test/resources/geckodriver"; System.out.println("******** " + path); System.setProperty("webdriver.gecko.driver", path); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); capabilities.setCapability("networkConnectionEnabled", true); capabilities.setCapability("browserConnectionEnabled", true); WebDriver driver = new RemoteWebDriver( new URL("http://localhost:4444"), capabilities); // WebDriver driver = new MarionetteDriver(capabilities); return driver; }
@Test public void testDriver() throws IOException { WebDriver driver = new RemoteWebDriver(toUrl("http://localhost:9515"), DesiredCapabilities.chrome()); driver.get(URL2); String response = driver.getPageSource(); Document doc = Jsoup.connect(URL2).ignoreContentType(true).get(); Elements scriptTags = doc.select("body"); // get All functions try { String result = (String) engine.eval(response); } catch (ScriptException e) { e.printStackTrace(); } log.info("PageSource " + response); driver.quit(); }
/** * Run a capability. */ private void runSequentialIndex(final WebDriver[] drivers, final boolean[] success, final int driverIndex, final DesiredCapabilities capability) { AbstractSequentialSeleniumTest seleniumTest = this; try { final WebDriver driver = getRemoteDriver(capability); drivers[driverIndex] = driver; seleniumTest = this.getClass().newInstance(); cloneAndRun(seleniumTest, driver, capability); success[driverIndex] = true; } catch (final Exception e) { log.error("Unable to build the driver for requested capability, other tests are not interrupted : " + capability, e); } finally { cleanup(); seleniumTest.cleanup(); } }
@Before public void setUp() throws Exception { File classpathRoot = new File(System.getProperty("user.dir")); File appDir = new File(classpathRoot, "/apps/"); File app = new File(appDir.getCanonicalPath(), "Financius.v0.18.2.apk"); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName", ""); // device UID from adb capabilities.setCapability("platformVersion", "6.0.1"); // android version capabilities.setCapability("platformName", "Android"); capabilities.setCapability("app", app.getAbsolutePath()); capabilities.setCapability("appPackage", "com.code44.finance"); // package name capabilities.setCapability("appWaitActivity", "com.code44.finance.*"); // default activity capabilities.setCapability("no-reset", "true"); capabilities.setCapability("full-reset", "false"); driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); }
public void clickWithNativeEvents() throws Throwable { DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("nativeEvents", true); driver = new JavaDriver(new JavaProfile(), caps, caps); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame.setLocationRelativeTo(null); frame.setVisible(true); } }); WebElement element1 = driver.findElement(By.name("click-me")); element1.click(); AssertJUnit.assertTrue(buttonClicked); buttonClicked = false; new Actions(driver).click().perform(); AssertJUnit.assertTrue(buttonClicked); AssertJUnit.assertTrue(buttonMouseActions.toString().contains("clicked(1)")); buttonMouseActions.setLength(0); new Actions(driver).contextClick().perform(); AssertJUnit.assertTrue(buttonMouseActions.toString(), buttonMouseActions.toString().contains("pressed(3-popup)") || buttonMouseActions.toString().contains("released(3-popup)")); }
private static WebDriver createRemoteDriver(String url, DesiredCapabilities caps, Boolean checkForProxy, Properties props) { try { if (isAppiumNative(url, caps.asMap())) { if (isAndroidNative(caps.asMap())) { return new io.appium.java_client.android.AndroidDriver(new URL(url), caps); } else if (isIOSNative(caps.asMap())) { return new io.appium.java_client.ios.IOSDriver(new URL(url), caps); } } if (url == null) { return new RemoteWebDriver(caps); } if (checkForProxy) { return new RemoteWebDriver(RemoteProxy.getProxyExecutor(new URL(url), props), caps); } return new RemoteWebDriver(new URL(url), caps); } catch (MalformedURLException ex) { LOGGER.log(Level.SEVERE, ex.getMessage(), ex); } return null; }
public void dndWithCopy() throws Throwable { DesiredCapabilities caps = new DesiredCapabilities(); // caps.setCapability("nativeEvents", true); driver = new JavaDriver(caps, caps); WebElement list = driver.findElement(By.cssSelector("list")); assertEquals( "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 4\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]", list.getAttribute("content")); WebElement listitem1 = driver.findElement(By.cssSelector("list::nth-item(1)")); WebElement listitem5 = driver.findElement(By.cssSelector("list::nth-item(5)")); listitem1.click(); driver.clearlogs(LogType.DRIVER); Keys copyKey = Keys.ALT; if (Platform.isWindows()) { copyKey = Keys.CONTROL; } new Actions(driver).keyDown(copyKey).dragAndDrop(listitem1, listitem5).keyUp(copyKey).perform(); waitTillDropCompletes( "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]", list); assertEquals( "[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]", list.getAttribute("content")); }
/** * Prepare the thread instances. */ private Thread[] prepareThreads(final WebDriver[] drivers, final boolean[] success) { // NOPMD final Thread[] threads = new Thread[repeatedCapabilities.length]; // NOPMD -- thread for (int index = 0; index < repeatedCapabilities.length; index++) { final int driverIndex = index; final DesiredCapabilities capability = repeatedCapabilities[driverIndex]; success[driverIndex] = false; try { final WebDriver driver = getRemoteDriver(capability); drivers[driverIndex] = driver; threads[driverIndex] = prepareThread(driver, driverIndex, success, capability); } catch (final Exception e) { log.error("Unable to connect the remote web driver, other tests are not interrupted : " + capability, e); } finally { cleanup(); } } return threads; }
/** * Sets the target browser binary path in chromeOptions if it exists in configuration. * * @param capabilities * The global DesiredCapabilities */ private void setChromeOptions(final DesiredCapabilities capabilities, ChromeOptions chromeOptions) { // Set custom downloaded file path. When you check content of downloaded file by robot. HashMap<String, Object> chromePrefs = new HashMap<>(); chromePrefs.put("download.default_directory", System.getProperty("user.dir") + File.separator + "downloadFiles"); chromeOptions.setExperimentalOption("prefs", chromePrefs); // Set custom chromium (if you not use default chromium on your target device) String targetBrowserBinaryPath = Context.getWebdriversProperties("targetBrowserBinaryPath"); if (targetBrowserBinaryPath != null && !"".equals(targetBrowserBinaryPath)) { chromeOptions.setBinary(targetBrowserBinaryPath); } capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions); }
/** * Generates a htmlunit webdriver. * * @return * A htmlunit webdriver */ private WebDriver generateHtmlUnitDriver() { logger.info("Generating HtmlUnit driver..."); final DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit(); capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true); capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT); capabilities.setJavascriptEnabled(true); setLoggingLevel(capabilities); // Proxy configuration if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) { capabilities.setCapability(CapabilityType.PROXY, Context.getProxy()); } return new HtmlUnitDriver(capabilities); }
public Capabilities getCapabilities() throws IOException { String capabilitiesFile = properties.getProperty("capabilities"); Properties capsProps = new Properties(); capsProps.load(SuiteConfiguration.class.getResourceAsStream(capabilitiesFile)); DesiredCapabilities capabilities = new DesiredCapabilities(); for (String name : capsProps.stringPropertyNames()) { String value = capsProps.getProperty(name); if (value.toLowerCase().equals("true") || value.toLowerCase().equals("false")) { capabilities.setCapability(name, Boolean.valueOf(value)); } else if (value.startsWith("file:")) { capabilities.setCapability(name, new File(".", value.substring(5)).getCanonicalFile().getAbsolutePath()); } else { capabilities.setCapability(name, value); } } return capabilities; }
/** * 启动ios的safari浏览器 * * @param noReset */ private void createIOSSafariDriver(Boolean noReset) { capabilities = new DesiredCapabilities(); capabilities.setCapability("platformName", property.getProperty("platformName")); capabilities.setCapability("platformVersion", property.getProperty("platformVersion")); capabilities.setCapability("deviceName", property.getProperty("deviceName")); capabilities.setCapability("browserName", property.getProperty("browserName", "Safari")); capabilities.setCapability("autoAcceptAlerts", property.getProperty("autoAcceptAlerts", "True")); // debug时,等待时间调大点!! capabilities.setCapability("newCommandTimeout", property.getProperty("newCommandTimeout")); capabilities.setCapability("noReset", noReset); // 不卸载、不重装 capabilities.setCapability("noSign", "true"); // 重置输入法,并且设置可以中文输入 capabilities.setCapability("unicodeKeyboard", "True"); capabilities.setCapability("resetKeyboard", "True"); try { driver = new IOSDriver<MobileElement>(new URL(property.getProperty("remote.address")), capabilities); } catch (Exception e) { e.printStackTrace(); AssertUtil.fail("初始化对象失败,e = " + e.getMessage()); } }
@Before public void startApp() throws Exception { DesiredCapabilities capabilities = new DesiredCapabilities(); Map<String, Object> baseState = new HashMap<>(); baseState.put("type", "NATIVE"); baseState.put("executable", APP); baseState.put("locator", "//Window"); capabilities.setCapability("appdriver-basestate", baseState); Map<String, Object> options = new HashMap<>(); options.put("closeOnQuit", true); capabilities.setCapability("appdriver-options", options); driver = new RemoteWebDriver(new URL("http://localhost:8080"), capabilities); }
private ServerSideSession safeStart(DesiredCapabilities cap) { ServerSideSession session = null; try { // init session session = getServer().createSession(cap); if (session == null) { throw new SessionNotCreatedException( "The server is currently shutting down and doesn't accept new tests."); } // start session session.start(); return session; } catch (Exception e) { // TODO(user): Clean this up to meet logging best practices (should not log and throw). logger.atSevere().withCause(e).log("Error starting the session"); if (session != null) { session.stop(); } throw new SessionNotCreatedException(e.getMessage(), e); } }
@Override public Response handle() throws Exception { JSONArray res = new JSONArray(); for (ServerSideSession s : getServer().getSessions()) { JSONObject session = new JSONObject(); session.put("id", s.getSessionId()); session.put("capabilities", new DesiredCapabilities()); res.put(session); } Response resp = new Response(); resp.setSessionId("dummy one"); resp.setStatus(0); resp.setValue(res.toString()); return resp; }
@Override public WebDriver createDriver(DesiredCapabilities capabilities) { Configuration.startMaximized = false; Configuration.captureJavascriptErrors = false; capabilities.setCapability(MobileCapabilityType.VERSION, "4.4.2"); capabilities.setCapability("automationName", "Appium"); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("deviceName", "0123456789ABCDEF"); capabilities.setCapability(APP_PACKAGE, "com.android.calculator2"); capabilities.setCapability(APP_ACTIVITY, "com.android.calculator2.Calculator"); try { return new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); } catch (MalformedURLException e) { throw new RuntimeException(e); } }
public static WebDriver getDriverUsingIf(DesiredCapabilities desiredCapabilities) { if (desiredCapabilities == null) { throw new IllegalStateException("DesiredCapabilities are missing!"); } final String browser = desiredCapabilities.getBrowserName(); if (CHROME.equalsIgnoreCase(browser)) { return new ChromeDriver(desiredCapabilities); } else if (FIREFOX.equalsIgnoreCase(browser)) { return new FirefoxDriver(desiredCapabilities); } else if (browser.isEmpty()) { throw new IllegalStateException("'browser' capability is missing!"); } throw new IllegalArgumentException(desiredCapabilities.getBrowserName() + " browser is not supported!"); }
@Override public WebDriver createDriver(DesiredCapabilities capabilities) { Map<String, Object> preferences = new Hashtable<>(); preferences.put("profile.default_content_settings.popups", 0); preferences.put("download.prompt_for_download", "false"); String downloadsPath = System.getProperty("user.home") + "/Downloads"; preferences.put("download.default_directory", loadSystemPropertyOrDefault("fileDownloadPath", downloadsPath)); preferences.put("plugins.plugins_disabled", new String[]{ "Adobe Flash Player", "Chrome PDF Viewer"}); ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("prefs", preferences); capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); capabilities.setCapability(ChromeOptions.CAPABILITY, options); return new ChromeDriver(capabilities); }
protected DesiredCapabilities createCapabilities(DriversSettings driversSettings) { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, driversSettings.getDeviceName()); capabilities.setCapability(MobileCapabilityType.UDID, driversSettings.getUDID()); String absolutePath = fileUtils.relativeToAbsolutePath(driversSettings.getFilePath()); capabilities.setCapability(MobileCapabilityType.APP, absolutePath); capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, driversSettings.getNewCommandTimeoutInSeconds()); capabilities.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true); return capabilities; }
/** * Sequentially run the desired capabilities. */ protected void runSequential() { // NOPMD -- thread final WebDriver[] drivers = new WebDriver[repeatedCapabilities.length]; final boolean[] success = new boolean[repeatedCapabilities.length]; for (int index = 0; index < repeatedCapabilities.length; index++) { final int driverIndex = index; final DesiredCapabilities capability = repeatedCapabilities[driverIndex]; success[driverIndex] = false; runSequentialIndex(drivers, success, driverIndex, capability); } final List<String> faillures = checkResults(success); Assert.assertTrue("All browsers test failed", faillures.size() != success.length); Assert.assertEquals("Some browsers test failed", 0, faillures.size()); }
@Override public AppiumDriver createDriver(DriversSettings driversSettings, AppSettings appSettings) { DesiredCapabilities capabilities = createCapabilities(driversSettings); additionalCapabilities(driversSettings, capabilities); IOSDriver iosDriver = new IOSDriver(getRemoteAddress(driversSettings.getAppiumRemoteUrl()), capabilities); iosDriver.manage().timeouts().implicitlyWait(driversSettings.getImplicitlyWaitInSeconds(), TimeUnit.SECONDS); return iosDriver; }
private static void startIOSSpy() { try { if (wd == null) { DesiredCapabilities capabilities = new DesiredCapabilities(); for (String key : caps.keySet()) { capabilities.setCapability(key, caps.get(key)); } wd = new IOSDriver(new URL(url), capabilities); } } catch (Exception ex) { Logger.getLogger(IOSpy.class.getName()).log(Level.SEVERE, null, ex); Notification.show("Couldn't Connect to Device/Simulator Check Settings/Appium Logs"); } }
public WebDriverEx createWebDriver(DriverService driverService, DesiredCapabilities desiredCapabilities, SiteConfig siteConfig, DriverConfig driverConfig) throws IOException { driverService.start(); //自定义HttpClientFactory用于设置命令超时时间 ApacheHttpClient.Factory httpClientFactory = createHttpClientFactory(siteConfig, driverConfig); HttpCommandExecutor httpCommandExecutor = new HttpCommandExecutor( ImmutableMap.<String, CommandInfo>of(), driverService.getUrl(), httpClientFactory); WebDriverEx webDriver = new WebDriverEx(httpCommandExecutor, desiredCapabilities); webDriver.setDriverService(driverService); webDriver.setCreatedTime(new Date()); webDriver.manage().timeouts().implicitlyWait(driverConfig.getImplicitlyWait(), TimeUnit.MILLISECONDS); webDriver.manage().timeouts().pageLoadTimeout(driverConfig.getPageLoadTimeout(), TimeUnit.MILLISECONDS); webDriver.manage().timeouts().setScriptTimeout(driverConfig.getScriptTimeout(), TimeUnit.MILLISECONDS); return webDriver; }
public DesiredCapabilities createChromeDesiredCapabilities(SiteConfig siteConfig, DriverConfig driverConfig) { ChromeDesiredCapabilities capabilities = ChromeDesiredCapabilities.create(); capabilities.setImagesEnabled(false); capabilities.setFlashEnabled(false); capabilities.setAutomaticDownloadsEnabled(false); capabilities.setJavascriptEnabled(true); return capabilities; }
/** * Get an instance of an WebDriver. * * @param appiumServerUrl - servers URL * @param platformName - OS name (Android, IOS ...) * @param deviceName - device model name * @param app - mobile application to install/run * @return - an android driver connected via Appium */ public static AndroidDriver<?> driverStart(String appiumServerUrl, String platformName, String deviceName, String app){ DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("platformName", platformName); capabilities.setCapability("deviceName", deviceName); capabilities.setCapability("app", app); try { driver = new AndroidDriver<>(new URL(appiumServerUrl), capabilities); } catch (MalformedURLException e) { throw new TestCaseFailure("Could not start remote driver! ", e); } logger.log("WebDriver: " + driver.getClass().getCanonicalName()); setDefaultImplicitWait(); logger.log("implicit wait: " + defaultWait + "s"); return driver; }
/** * @param engineCapMap 用于保存浏览器配置的返回结果 * @param enginePro 引擎配置集合 */ public CapabilityConfig(Map<String, DesiredCapabilities> engineCapMap, Properties enginePro) { this.engineCapMap = engineCapMap; this.enginePro = enginePro; }
/** * 火狐浏览器配置 */ private void firefox() { DesiredCapabilities capability = DesiredCapabilities.firefox(); capability.setCapability("marionette", true); engineCapMap.put(DRIVER_FIREFOX, capability); }
private static ThreadLocal<WebDriver> getAndroidDriverThreadLocal(DesiredCapabilities... params) throws IOException { final Properties prop = new Properties(); FileInputStream input = new FileInputStream("src/main/resources/config.properties"); prop.load(input); System.out.println(prop.getProperty("appPath")); System.out.println(prop.getProperty("application")); System.out.println(prop.getProperty("device")); System.out.println(prop.getProperty("platform")); System.out.println(prop.getProperty("appiumServer")); System.out.println("********************InIt initiated ************"); File appDir = new File(prop.getProperty("appPath")); File app = new File(appDir, prop.getProperty("application")); //mandatory capabilities capabilities.setCapability("deviceName", prop.getProperty("device")); // capabilities.setCapability("deviceName", "ba99f4b7"); capabilities.setCapability("platformName", prop.getProperty("platform")); capabilities.setCapability("app", app.getAbsolutePath()); //capabilities.setCapability("noReset",false); return new ThreadLocal<WebDriver>() { @Override protected WebDriver initialValue() { AndroidDriver<WebElement> androidDriver = null; try { androidDriver = new AndroidDriver<WebElement>(new URL(prop.getProperty("appiumServer")), capabilities); } catch (MalformedURLException e) { e.printStackTrace(); } return androidDriver; } }; }
private static Capabilities dropCapabilities(Capabilities capabilities, String... keysToRemove) { if (capabilities == null) { return new DesiredCapabilities(); } final Set<String> toRemove = Sets.newHashSet(keysToRemove); DesiredCapabilities caps = new DesiredCapabilities(Maps.filterKeys(capabilities.asMap(), new Predicate<String>() { @Override public boolean apply(String key) { return !toRemove.contains(key); } })); return caps; }
public void loggingWorks() { LoggingPreferences prefs = new LoggingPreferences(); prefs.enable(LogType.DRIVER, Level.INFO); DesiredCapabilities caps = JavaDriver.defaultCapabilities(); caps.setCapability(CapabilityType.LOGGING_PREFS, prefs); driver = new JavaDriver(caps, caps); LogEntries logEntries = driver.manage().logs().get(LogType.DRIVER); List<LogEntry> all = logEntries.getAll(); AssertJUnit.assertEquals(2, all.size()); AssertJUnit.assertTrue(all.get(0).getMessage().contains("A new session created. sessionID = ")); }
private static DesiredCapabilities capabilitiesSafari() { DesiredCapabilities capabilities = DesiredCapabilities.safari(); SafariOptions options = new SafariOptions(); options.setUseCleanSession(true); capabilities.setCapability(SafariOptions.CAPABILITY, options); return capabilities; }
/** * Inject desired capabilities from configuration into the specified * DesiredCapabilities object. */ private static void injectCapsFromConfig(DesiredCapabilities caps) { Object capsFromConfig = config.get("appium.desiredCapabilities", null); if (capsFromConfig instanceof Map) { Map<String, Object> capsFromConfigMap = (Map) capsFromConfig; for (Map.Entry entry : capsFromConfigMap.entrySet()) { if (entry.getValue() != null) { caps.setCapability(entry.getKey().toString(), entry.getValue()); } } } }
/** * Create the driver instance */ @Override protected void prepareDriver() throws Exception { if (!isLocalTest()) { capability = DesiredCapabilities.phantomjs(); } super.prepareDriver(); }
public void succeedsWhenRequestingNativeEventsCapability() throws Throwable { DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", Platform.getCurrent()); caps.setCapability("nativeEvents", true); driver = new JavaDriver(caps, caps); Capabilities capabilities = ((RemoteWebDriver) driver).getCapabilities(); AssertJUnit.assertTrue(capabilities.is("nativeEvents")); }
protected void ieDriver() { DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false); capabilities.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, false); capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false); capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true); capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true); capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); System.setProperty("webdriver.ie.driver","./src/main/resources/iedriver/IEDriverServer.exe"); driver = new InternetExplorerDriver(capabilities); driver.manage().window().maximize(); }
@BeforeMethod public void createDriver() { System.setProperty(Constants.PROP_PROJECT_FRAMEWORK, Constants.FRAMEWORK_SWING); JavaProfile profile = new JavaProfile(LaunchMode.JAVA_COMMAND_LINE); File f = findFile(); profile.addClassPath(f); profile.setRecordingPort(startRecordingServer()); profile.setMainClass("com.sun.swingset3.SwingSet3"); DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY); driver = new JavaDriver(profile, caps, caps); }
@BeforeClass public void createDriver() { System.setProperty(Constants.PROP_PROJECT_FRAMEWORK, Constants.FRAMEWORK_SWING); JavaProfile profile = new JavaProfile(LaunchMode.COMMAND_LINE); File f = findFile(); profile.setCommand(f.getAbsolutePath()); profile.setRecordingPort(startRecordingServer()); DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY); driver = new JavaDriver(profile, caps, caps); }
@Override public WebDriver getWebDriver() { System.setProperty("webdriver.chrome.driver", "src/test/resources/chromedriver.2.27"); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); return new ChromeDriver(capabilities); }
@Override public WebDriver getWebDriver() { System.setProperty("webdriver.gecko.driver", "src/test/resources/geckodriver.v0.11.1.mac"); DesiredCapabilities capabilities=DesiredCapabilities.firefox(); WebDriver driver = new FirefoxDriver(capabilities); return driver; }
public static WebDriver getFirefoxDriver(String pathToFirefoxExecutable) { String path = "src/test/resources/geckodriver"; System.setProperty("webdriver.gecko.driver", path); System.setProperty("webdriver.firefox.bin", pathToFirefoxExecutable); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); capabilities.setCapability("networkConnectionEnabled", true); capabilities.setCapability("browserConnectionEnabled", true); WebDriver driver = new MarionetteDriver(capabilities); return driver; }