@Test
  public void testRemoteWebDriver() {
    DesiredCapabilities cap = new DesiredCapabilities();
    cap.setPlatform(Platform.ANY);
    cap.setBrowserName("opera");
    RemoteWebDriver driver = null;
    try {
      driver = new RemoteWebDriver(new URL("http://192.168.1.176:4444/wd/hub"), cap);
    } catch (MalformedURLException e) {
      e.printStackTrace();
    }
    // Navigate to Google using firefox
    driver.get("http://www.google.com");
    driver
        .findElement(By.name("q"))
        .sendKeys("selenium automation using grid on windows 8.1 with firefox machine");
    driver = (RemoteWebDriver) new Augmenter().augment(driver);
    File srcFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    try {
      FileUtils.copyFile(srcFile, new File("remoteScreenshot.jpg"));
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    System.out.println(driver.getCurrentUrl());
    driver.quit();
  }
Exemplo n.º 2
0
 /** @return True if there is another step to execute. */
 public boolean hasNext() {
   boolean hasNext = stepIndex < script.steps.size() - 1;
   if (!hasNext && driver != null) {
     log.debug("Quitting driver.");
     driver.quit();
   }
   return hasNext;
 }
Exemplo n.º 3
0
 /** Resets the script's progress and closes the driver if needed. */
 public void reset() {
   log.debug("Resetting test run.");
   vars.clear();
   stepIndex = -1;
   if (driver != null) {
     driver.quit();
   }
 }
Exemplo n.º 4
0
  @After
  public void tearDown() throws Exception {
    // SetupDriver.exit();
    if (driver != null) driver.quit();

    System.out.println("Driver ShutDown");
    // process.destroy();
  }
 /** Attempts to shut down {@link RemoteWebDriver} and destroys all related information */
 @Override
 public void destroy() {
   if (enclosedDriver == null) return;
   try {
     enclosedDriver.quit();
   } catch (WebDriverException e) { // it may be already dead
     return;
   }
 }
  @Test
  public void whenGetCapabilitiesFromRunningSessionThenItShouldBeSerializable() {
    RemoteWebDriver driver = new RemoteWebDriver(HUB_URL, DesiredCapabilities.firefox());

    Capabilities initializedCapabilities = driver.getCapabilities();

    assertTrue(
        "Capabilities obtained from running session should be serializable",
        initializedCapabilities instanceof Serializable);

    driver.quit();
  }
Exemplo n.º 7
0
 /**
  * Runs the entire (rest of the) script.
  *
  * @return True if the script ran successfully, false if a verification failed. Any other failure
  *     throws an exception.
  * @throws RuntimeException if the script failed.
  */
 public boolean finish() {
   boolean success = true;
   try {
     while (hasNext()) {
       success = next() && success;
     }
   } catch (RuntimeException e) {
     // If the script terminates, the driver will be closed automatically.
     try {
       driver.quit();
     } catch (Exception e2) {
     }
     throw e;
   }
   return success;
 }
  public static void main(String[] args)
      throws MalformedURLException, UnsupportedEncodingException {

    System.out.println("Run started");
    driver = setupDriver(true);

    try {

      ArrayList<ArrayList<String>> list1 = new ArrayList<ArrayList<String>>();
      LinksTest listLinks1 = new LinksTest(driver);

      list1 = listLinks1.linksTest("www.google.co.il");
      list1 = listLinks1.getBrokenLinks();
      list1 = listLinks1.getListOfPageLinks();
      list1 = listLinks1.getLoadFailedLinks();
      list1 = listLinks1.getSucceededLinks();

      LinksTest listLinks2 = new LinksTest(driver, "www.google.co.il");
      list1 = listLinks2.linksTest();

      /*listLinks.getBrokenLinks();
      listLinks.getPageLinks();
      listLinks.getPageLinks("www.nxc.co.il");
      listLinks.printPageLinksStatus();
      listLinks.testLinks();
      listLinks.printPageLinksStatus();
      ArrayList<ArrayList<String>> links = listLinks.getBrokenLinks();
      links = listLinks.getLoadFailedLinks();
      links = listLinks.getSucceededLinks();*/
      /*listLinks.setUrl("www.google.co.il");
      listLinks.printPageLinksStatus();
      listLinks.getPageLinks();
      listLinks.printPageLinksStatus();
      listLinks.testLinks();
      listLinks.printPageLinksStatus();
      ArrayList<ArrayList<String>> links = listLinks.getBrokenLinks();
      links = listLinks.getLoadFailedLinks();
      links = listLinks.getSucceededLinks();*/

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      driver.quit();
    }

    System.out.println("Run ended");
  }
Exemplo n.º 9
0
  @Test
  public void goToGoogle() {
    PlatFormDTO platform = new PlatFormDTO("win7", "internet explorer");
    RemoteWebDriver remote = new UsingSeleniumGrid().getRemoteWebDriver(platform);

    Sample_page su = PageFactory.initElements(remote, Sample_page.class);

    int size = su.getCheckboxSize();
    ArrayList<String> al = new Recursive().getRecursive(1, size);
    remote.quit();

    for (int i = 0; i < al.size(); i++) {
      Sample_page s =
          PageFactory.initElements(
              new UsingSeleniumGrid().getRemoteWebDriver(platform), Sample_page.class);
      s.getCheckboxtabname(al.get(i));
    }
    assertThat(true, is(false));
  }
Exemplo n.º 10
0
  @AfterSuite(alwaysRun = true)
  public void tearDown(ITestContext ctx) throws Throwable {
    try {
      ReportStampSupport.calculateSuiteExecutionTime();

      HtmlReportSupport.createHtmlSummaryReport(browser, url);
      closeSummaryReport();
      if (browser.equalsIgnoreCase("iphone")) {
        // Iosdriver.removeApp(bundleID);
      }
      driver.quit();
    } catch (Exception e) {
      e.printStackTrace();
    } /*finally {
      	if (browser.contains("Android")) {
      		RedPlanetUtils.stopAppium();
      	} else if (browser.contains("iPhone")) {
      		RedPlanetUtils.stopAppiumForIos();
      	}
      }*/
  }
Exemplo n.º 11
0
 @AfterMethod(alwaysRun = true)
 public static void tearDownMethod() throws Throwable {
   try {
     ReportStampSupport.calculateTestCaseExecutionTime();
     closeDetailedReport();
     if (FailNum != 0) {
       failCounter = failCounter + 1;
       testResults.put(HtmlReportSupport.tc_name, "FAIL");
     } else {
       testResults.put(HtmlReportSupport.tc_name, "PASS");
       passCounter = passCounter + 1;
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     if ((browser.toLowerCase().contains("iphone"))) {
       Iosdriver.closeApp();
     } else if (browser.toLowerCase().contains("android")) {
       // AndroidDriver2.closeApp();
     } else {
       driver.quit();
     }
   }
 }
Exemplo n.º 12
0
 @After
 public void quitBrowser() {
   Driver.quit();
 }
Exemplo n.º 13
0
 @After
 public void closeBrowser() {
   driver.quit();
 }
Exemplo n.º 14
0
 @After
 public void shutDown() {
   driver.quit();
 }
Exemplo n.º 15
0
 @AfterMethod
 public void Closebrowser() {
   driver.quit();
 }
 @AfterClass
 public static void destroyBrowser() {
   if (driver != null) {
     driver.quit();
   }
 }
Exemplo n.º 17
0
 @AfterClass
 public void stopDriver() {
   if (driver != null) {
     driver.quit();
   }
 }