List of usage examples for org.openqa.selenium.remote RemoteWebDriver RemoteWebDriver
public RemoteWebDriver(URL remoteAddress, Capabilities capabilities)
From source file:com.mycompany.myproject.sample.simple.DemoWebTest.java
License:Apache License
@Test public void seleniumDemo() throws Exception { // Hard coded to firefox DesiredCapabilities caps = DesiredCapabilities.firefox(); // Hard coded selenium host RemoteWebDriver driver = new RemoteWebDriver(new URL("http://192.168.99.100:4444/wd/hub"), caps); driver.get("http://google.com"); String source = driver.getPageSource(); File file = driver.getScreenshotAs(OutputType.FILE); //TODO log the screenshot and source to a report // don't forget to close the WebDriver connection driver.quit();/*from w w w.j ava 2 s. com*/ }
From source file:com.mycompany.webcalculator.OperationsSeleniumTest.java
@Test public void AdditionSeleniumtest() throws Exception { //System.setProperty("webdriver.firefox.bin", "C:\\Users\\katrina.h.quililan\\AppData\\Local\\Mozilla Firefox\\firefox.exe"); DesiredCapabilities capability = DesiredCapabilities.firefox(); //WebDriver driver = new RemoteWebDriver(new URL("http://cioadmin:cio_1234@selenium.52.54.45.25.xip.io///wd/hub"), capability); WebDriver driver = new RemoteWebDriver( new URL("http://cioadmin:initial_1234@selenium.52.70.111.102.xip.io///wd/hub"), capability); //WebDriver driver = new FirefoxDriver(); //driver.get("http://www.google.com"); login(driver, "https://www.tests.com/login", "katrinablanca", "sticker"); dispose(driver);/* www. j a v a 2 s . com*/ }
From source file:com.nexenta.qa.bs.wz.Test1Reg.java
@BeforeClass public void setUPbro() throws MalformedURLException { //Get Props//from ww w . j ava 2s .co m Properties prop = new Properties(); reg = new RegPanel(); InputStream input = null; try { input = new FileInputStream(System.getProperty("propFile")); prop.load(input); } catch (IOException ex) { ex.printStackTrace(); } finally { if (input != null) { try { input.close(); } catch (IOException e) { e.printStackTrace(); } } } // create driver driver = new RemoteWebDriver(new URL("http://" + prop.getProperty("WCM") + ":4444/wd/hub"), DesiredCapabilities.firefox()); driver.get("http://" + prop.getProperty("MUT") + ":8457/register/"); String needlogin = driver.getTitle(); logger.info(needlogin); if (needlogin.equals("NMV Login")) { WebElement nameu = driver.findElement(By.name("_nmv_username_")); WebElement passu = driver.findElement(By.name("_nmv_password_")); nameu.sendKeys("admin"); passu.sendKeys("nexenta"); driver.findElement(By.name("_nmv_login_")).click(); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); } }
From source file:com.nexenta.qa.bs.wz.Test3Registration.java
@BeforeClass public void setUPbro() throws MalformedURLException { // create driver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.firefox()); reg = new RegPanel(); driver.get("http://192.168.112.219:8457/register/"); }
From source file:com.numenta.htmit.mobile.test.behavior.MobileAppTest.java
License:Open Source License
@BeforeClass @Parameters({ "deviceName", "version", "sauceUserName", "sauceAccessKey" }) public void setUp(String deviceName, String platformVersion, String sauceUserName, String sauceAccessKey) throws Exception { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("name", "HTM-IT mobile Testing"); capabilities.setCapability("app", "sauce-storage:htm-it-mobile-app-release.apk"); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("device-orientation", "portrait"); capabilities.setCapability("deviceName", deviceName); capabilities.setCapability("platformVersion", platformVersion); capabilities.setCapability("androidPackage", "com.numenta.htmit.mobile"); capabilities.setCapability("appActivity", "com.numenta.htmit.mobile.SplashScreenActivity"); driver = new RemoteWebDriver( new URL("http://" + sauceUserName + ":" + sauceAccessKey + "@ondemand.saucelabs.com:80/wd/hub"), capabilities);/* w w w . j a va 2s. co m*/ Thread.sleep(1000); }
From source file:com.partnet.automation.selenium.AbstractConfigurableDriverProvider.java
License:Apache License
/** * Helper method to launch remote web driver. * * At times there are issues with starting the remote web driver. For firefox, * problems with locking port 7054 can arise. * * See the Selenium <a/*from w ww . j a v a 2 s .co m*/ * href="https://code.google.com/p/selenium/issues/detail?id=4790">bug</a> for * more info * * A special case needs to be performed for the Android browser, since it can not be cast to {@link RemoteWebDriver} * * @param capabilities web driver capabilities. * @return {@link WebDriver} instance of the remote web driver * */ protected WebDriver initRemoteWebDriver(DesiredCapabilities capabilities) { URL remoteUrl = getRemoteSeleniumUrl(); LOG.debug("Remote Selenium URL: {}", remoteUrl.toString()); WebDriver driver = null; boolean isAndroid = false; int tries = 1; if (capabilities.getCapability(CapabilityType.BROWSER_NAME).equals(ANDROID_BROWSER_NAME)) { isAndroid = true; } while (driver == null) { LOG.debug("Try {} {}", tries, capabilities.toString()); try { if (isAndroid) { driver = new AndroidDriver(remoteUrl, capabilities); } else { driver = new RemoteWebDriver(remoteUrl, capabilities); } } catch (WebDriverException e) { LOG.error("Remote WebDriver was unable to start! " + e.getMessage(), e); if (tries >= Integer.getInteger(REMOTE_WEBDRIVER_RETRY_ATTEMPTS, 10)) { throw e; } sleep(Integer.getInteger(REMOTE_WEBDRIVER_RETRY_PAUSE_MILLIS, 5000) * tries); tries++; driver = null; } } if (!isAndroid) { // allow screenshots to be taken driver = new Augmenter().augment(driver); } // Allow files from the host to be uploaded to a remote browser ((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector()); return driver; }
From source file:com.photon.phresco.Screens.BaseScreen.java
License:Apache License
public void instantiateBrowser(String selectedBrowser, String selectedPlatform, String applicationURL, String applicationContext) throws ScreenException, MalformedURLException { URL server = new URL("http://localhost:4444/wd/hub/"); if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_CHROME)) { log.info("-------------***LAUNCHING GOOGLECHROME***--------------"); try {//www . j a va 2s . com capabilities = new DesiredCapabilities(); capabilities.setBrowserName("chrome"); } catch (Exception e) { e.printStackTrace(); } } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_IE)) { log.info("---------------***LAUNCHING INTERNET EXPLORE***-----------"); try { capabilities = new DesiredCapabilities(); capabilities.setJavascriptEnabled(true); capabilities.setBrowserName("iexplorer"); } catch (Exception e) { e.printStackTrace(); } } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_OPERA)) { log.info("-------------***LAUNCHING OPERA***--------------"); try { capabilities = new DesiredCapabilities(); capabilities.setBrowserName("opera"); capabilities.setCapability("opera.autostart ", true); System.out.println("-----------checking the OPERA-------"); } catch (Exception e) { e.printStackTrace(); } } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_SAFARI)) { log.info("-------------***LAUNCHING SAFARI***--------------"); try { capabilities = new DesiredCapabilities(); capabilities.setBrowserName("safari"); /* capabilities.setCapability("safari.autostart ", true);*/ System.out.println("-----------checking the SAFARI-------"); } catch (Exception e) { e.printStackTrace(); } } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_FIREFOX)) { log.info("-------------***LAUNCHING FIREFOX***--------------"); capabilities = new DesiredCapabilities(); capabilities.setBrowserName("firefox"); } else if (selectedBrowser.equalsIgnoreCase(Constants.HTML_UNIT_DRIVER)) { log.info("-------------***HTML_UNIT_DRIVER***--------------"); capabilities = new DesiredCapabilities(); capabilities.setBrowserName("htmlunit"); /*URL server = new URL("http://testVM:4444/wd/hub"); new RemoteWebDriver(new Url("http://testVM:4444/wd/hub");*/ System.out.println("-----------checking the HTML_UNIT_DRIVER-------"); // break; // driver = new RemoteWebDriver(server, capabilities); } else { throw new ScreenException("------Only FireFox,InternetExplore and Chrome works-----------"); } if (selectedPlatform.equalsIgnoreCase("WINDOWS")) { capabilities.setCapability(CapabilityType.PLATFORM, Platform.WINDOWS); } else if (selectedPlatform.equalsIgnoreCase("LINUX")) { capabilities.setCapability(CapabilityType.PLATFORM, Platform.LINUX); } else if (selectedPlatform.equalsIgnoreCase("MAC")) { capabilities.setCapability(CapabilityType.PLATFORM, Platform.MAC); } driver = new RemoteWebDriver(server, capabilities); driver.get(applicationURL + applicationContext); }
From source file:com.pluribus.vcf.helper.TestSetup.java
public void startDriver(String vcfIp, String browser, String bsUserId, String bsKey) throws Exception { HashMap<String, String> bsLocalArgs = new HashMap<String, String>(); String sessionId = null;//ww w. ja va2 s . c o m String command = null; SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMddhhmmss"); String dateAsString = simpleDateFormat.format(new Date()); String localId = "convergenceTest" + dateAsString; bsLocalArgs.put("localIdentifier", localId); bsLocalArgs.put("key", bsKey); //BrowserStack Key bsLocal.start(bsLocalArgs); DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("browser", browser); caps.setCapability("build", "VCFC SmokeTest Cases"); caps.setCapability("acceptSslCerts", "true"); caps.setCapability("browserstack.local", "true"); caps.setCapability("browserstack.debug", "true"); caps.setCapability("browserstack.idleTimeout", "150"); caps.setCapability("platform", "ANY"); caps.setCapability("browserstack.localIdentifier", localId); driver = new RemoteWebDriver( new URL("https://" + bsUserId + ":" + bsKey + "@hub-cloud.browserstack.com/wd/hub"), caps); driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS); driver.manage().window().maximize(); driver.manage().deleteAllCookies(); // Get a handle to the driver. This will throw an exception if a matching driver cannot be located driver.get("https://" + vcfIp); com.jcabi.log.Logger.info("Logfile", getBSLogs(bsUserId, bsKey)); }
From source file:com.saucelabs.selenium.client.factory.impl.DefaultSeleniumSPIImpl.java
License:Open Source License
@Override public WebDriver createWebDriver(SeleniumFactory factory, String browserURL, DesiredCapabilities capabilities) { if (!canHandle(factory.getUri())) return null; // doesn't belong to us try {//from w w w. j av a2 s. c om URL url = new URL(factory.getUri()); // since the browser start command parameter can contain arbitrary character that may // potentially interfere with the rules of the URL, allow the user to specify it through a property. String browserStartCommand = (String) factory.getProperty("browserStartCommand"); if (browserStartCommand == null) // getPath starts with '/', so trim it off // do URL decode, so that arbitrary strings can be passed in. browserStartCommand = URLDecoder.decode(url.getPath().substring(1), "UTF-8"); //todo translate browserStartCommand to DesiredCapabilities DesiredCapabilities desiredCapabilities = capabilities; desiredCapabilities.merge(DesiredCapabilities.firefox()); WebDriver driver = new RemoteWebDriver(url, desiredCapabilities); if (browserURL != null) { driver.get(browserURL); } return driver; } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid URL: " + factory.getUri(), e); } catch (UnsupportedEncodingException e) { // impossible throw new Error(e); } }
From source file:com.selenium.repo.core.SeleniumProvider.java
License:Open Source License
public SeleniumProvider(String gridUrl, String baseUrl) { DesiredCapabilities capabilities = DesiredCapabilities.chrome(); this.baseURL = baseUrl; try {//from w w w .j ava 2 s .co m this.driver = new RemoteWebDriver(new URL(gridUrl), capabilities); } catch (MalformedURLException e) { LOGGER.error(e.getMessage()); } browserDriver = new BrowserDriver(driver, this.baseURL); this.selenium = browserDriver.getSelenium(); }