/**
   * Download all the report attachments with a certain type. type - video, image, vital, network
   * Examples: downloadAttachment("video", "C:\\test\\video", "flv"); downloadAttachment("image",
   * "C:\\test\\Image", "jpg");
   */
  private void downloadAttachment(
      RemoteWebDriver driver, String type, String fileName, String suffix) throws IOException {
    try {
      String command = "mobile:report:attachment";
      boolean done = false;
      int index = 0;

      while (!done) {
        Map<String, Object> params = new HashMap<>();

        params.put("type", type);
        params.put("index", Integer.toString(index));

        String attachment = (String) driver.executeScript(command, params);

        if (attachment == null) {
          done = true;
        } else {
          File file = new File(fileName + index + "." + suffix);
          BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(file));
          byte[] bytes = OutputType.BYTES.convertFromBase64Png(attachment);
          output.write(bytes);
          output.close();
          index++;
        }
      }
    } catch (Exception ex) {
      System.out.println("Got exception " + ex);
    }
  }
 /**
  * Download the report. type - pdf, html, csv, xml Example: downloadReport(driver, "pdf",
  * "C:\\test\\report");
  */
 private void downloadReport(RemoteWebDriver driver, String type, String fileName)
     throws IOException {
   try {
     String command = "mobile:report:download";
     Map<String, Object> params = new HashMap<>();
     params.put("type", type);
     String report = (String) driver.executeScript(command, params);
     File reportFile = new File(fileName + "." + type);
     BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(reportFile));
     byte[] reportBytes = OutputType.BYTES.convertFromBase64Png(report);
     output.write(reportBytes);
     output.close();
   } catch (Exception ex) {
     System.out.println("Got exception " + ex);
   }
 }
  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");
  }