@Test
 public void test1() {
   extent.startTest("Test1", "Google page");
   GooglePage googlepage = PageFactory.initElements(driver, GooglePage.class);
   extent.log(LogStatus.PASS, "Google page navigated");
   googlepage.entervalue();
 }
 public void onFinish(ISuite arg0) {
   // TODO Auto-generated method stub
   // extent.flush();
   System.out.println("Suite Stopped");
   extent.endTest(logger);
   extent.flush();
 }
 @SuppressWarnings("unchecked")
 public static synchronized ExtentTest startTest(String testName, String desc, String deviceId) {
   ExtentTest test = extent.startTest(testName, desc).assignCategory(deviceId);
   extentTestMap.put((int) (long) (Thread.currentThread().getId()), test);
   @SuppressWarnings("rawtypes")
   Map sysInfo = new HashMap();
   sysInfo.put("Selenium Java Version", "2.48.2");
   sysInfo.put("Environment", "Prod");
   sysInfo.put("AppiumVersion", "3.3.0");
   extent.addSystemInfo(sysInfo);
   return test;
 }
public class TestFile {

  public static WebDriver driver;
  private ExtentReports extent = ExtentReports.get(TestFile.class);

  @BeforeTest
  public void beforeTest() {
    extent.init("TestNGBasicSample.html", true);
    SeleniumDriver selenium = new SeleniumDriver();
    driver = selenium.initializeDriver();
  }

  @Test
  public void test1() {
    extent.startTest("Test1", "Google page");
    GooglePage googlepage = PageFactory.initElements(driver, GooglePage.class);
    extent.log(LogStatus.PASS, "Google page navigated");
    googlepage.entervalue();
  }

  @Test
  public void test2() {
    extent.startTest("Test2", "it is second test");
    extent.log(LogStatus.INFO, "second test case");
  }

  @AfterTest
  public void afterTest() {

    driver.quit();
    extent.endTest();
  }
}
Beispiel #5
0
  public static ExtentReports Instance() {
    ExtentReports extent;
    String Path = "./Report1.html";
    System.out.println(Path);
    extent = new ExtentReports(Path, false);
    extent
        .config()
        .documentTitle("Automation Report")
        .reportName("Regression")
        .insertJs("$('.quick-test-summary + table th:nth-child(2)').text('StepsPassed');")
        .insertJs("$('.quick-test-summary + table th:nth-child(7)').text('Screenshots');")
        .insertJs("$('.quick-test-summary + table th:nth-child(3)').text('StepsFailed');")
        .insertJs("$('.quick-test-summary + table th:nth-child(8)').text('StepsSkipped');");

    return extent;
  }
  public void onTestStart(ITestResult tr) {

    System.out.println("TestCase started now====" + tr.toString());

    // extent = new
    // ExtentReports("D:\\Git\\Ideal-Automation\\Ideal_Application\\src\\com\\ideal\\selenium\\util\\1.testreport\\testreport.html");
    logger = extent.startTest(tr.getName());
    LogStatus status = logger.getRunStatus();
    System.out.println(status);
  }
  @AfterMethod
  public void tearDown(ITestResult result) {
    if (result.getStatus() == ITestResult.FAILURE) {
      // String screenshot_path = Utility.captureScreenshot(driver, result.getName());
      File scrfile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
      String screenshot_path = "C:\\Storage\\Report\\" + scrfile.getName();
      File tmp = new File(screenshot_path);
      try {
        FileUtils.copyFile(scrfile, tmp);
      } catch (Exception ex) {
        System.out.println("Exception::");
      }
      System.out.println("Path:" + screenshot_path);
      String image = logger.addScreenCapture(screenshot_path);
      logger.log(LogStatus.FAIL, "Title verification", image);
    }

    report.endTest(logger);
    report.flush();
  }
 @Test
 public void verifyURL() {
   logger = report.startTest("Verify Site URL");
   driver = new FirefoxDriver();
   driver.manage().window().maximize();
   logger.log(LogStatus.INFO, "Browser started ");
   driver.get("http://ebfs.bruteforcesolution.net/ebfs/index.php");
   logger.log(LogStatus.INFO, "BrueForce Site loaded successfully");
   String title = driver.getTitle();
   Assert.assertTrue(true);
   logger.log(LogStatus.PASS, "Title verified");
 }
 @Test
 public void verifyBlogTitle() {
   logger = report.startTest("VerifyBlogTitle");
   driver = new FirefoxDriver();
   driver.manage().window().maximize();
   logger.log(LogStatus.INFO, "Browser started ");
   driver.get("http://ebfs.bruteforcesolution.net/ebfs/index.php");
   logger.log(LogStatus.INFO, "Application is up and running");
   String title = driver.getTitle();
   Assert.assertTrue(title.contains("Power of Choice"));
   logger.log(LogStatus.PASS, "Title verified");
 }
 public static synchronized void endTest() {
   extent.endTest(extentTestMap.get((int) (long) (Thread.currentThread().getId())));
 }
  @SuppressWarnings("deprecation")
  public void verify_facualcal_onfresh_launch() throws InterruptedException, IOException {
    // Handling error / failures
    FactSteps = 1;

    // Report part invoking
    ExtentReports reporter = Driver.getInstance();
    logger = reporter.startTest("Verify Factual Call test case").assignCategory("Smoke_Test");
    logger.log(LogStatus.PASS, "Started Factual Call Testcase");
    System.out.println("Case Started");

    // reading filr from Propery file
    Driver.property();
    PropertyFile.property();

    // Report logs for Launching the app
    ATUReports.add("Launch the app", false);
    logger.log(LogStatus.PASS, "Launch the app");

    // run command for getting logs in idevicesyslog.log
    String[] str = {
      "/bin/bash",
      "-c",
      "/usr/local/bin/idevicesyslog.log  >>" + properties.getProperty("LogFilePath")
    };
    Process p = Runtime.getRuntime().exec(str);

    FactSteps = FactSteps + 1;
    BufferedReader r = new BufferedReader(new FileReader(properties.getProperty("LogFilePath")));

    String line = "";
    String allLine = "";

    while ((line = r.readLine()) != null) {
      System.out.println("Sys data is ::" + line);
    }

    String FilePath = properties.getProperty("LogFilePath");
    // Users/aparna/Desktop/syslog1.log";

    Map<String, String> mapkeys = new HashMap<String, String>();

    try {
      FileInputStream fstream = new FileInputStream(FilePath);
      BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
      String strLine;

      // / read log line by line ------ strLine = br.readLines(6, 10); /
      StringBuffer sb = new StringBuffer("");
      while ((strLine = br.readLine()) != null) {

        sb.append(strLine);
      }
      ATUReports.add("Verify the Factual values(FAUD,FGEO) in Feed_1 Call", false);
      logger.log(LogStatus.PASS, "Verify the Factual values(FAUD,FGEO) in Feed_1 Call");

      // Handle wrong data failure for log file
      //			if(!sb.toString().contains("7646/app_iphone_us/display"))
      //			{
      //				FactSteps=4+1;
      //				System.out.println("Log data is not correct");
      //				Assert.fail();
      //			}

      // Get sg values form pub ad call
      if (sb.toString().contains("Requesting ad: /7646/app_iphone_us/display/feed/feed_1")) {
        String req =
            sb.toString()
                .substring(
                    sb.toString()
                        .lastIndexOf(
                            "Requesting ad: /7646/app_iphone_us/display/feed/feed_1 with parameters: {"));
        req = req.substring(req.indexOf("{") + 1, req.indexOf("}"));
        String[] arrays = req.split(";");
        System.out.println("Verifing the " + req);
        for (String keys : arrays) {
          System.out.println("keys is::" + keys);
          if (keys.contains("=")) {
            String[] key = keys.split("=");
            // System.out.println(key[0] + "---"+key[1]);
            mapkeys.put(key[0], key[1]);
          }
        }
        for (Entry<String, String> entryKeys : mapkeys.entrySet()) {
          // System.out.println("key : "+entryKeys.getKey() + "----"+"value:"+entryKeys.getValue());
          if (entryKeys.getKey().contains("fgeo")) {
            String fgeo = entryKeys.getValue();
            System.out.println("fgeo values are :" + entryKeys.getValue());
            ATUReports.add("sg values are presented", false);
            logger.log(LogStatus.PASS, "sg values are present");
            // container.add(entryKeys.getValue());
            // sg.add(entryKeys.getValue());
            int size = fgeo.length();
            System.out.println("Size is  : " + size);
            fgeo = fgeo.substring(2, fgeo.lastIndexOf('"'));
            fgeo = fgeo.replaceAll(",", ", ");

            // System.out.println("sg1::"+sg1);
            fgeoval.add(fgeo);
            System.out.println("fgeo values and split data is ::" + fgeoval);
          }
        }

        // Get id values for lotame call

        Map<String, String> Factualkeys = new HashMap<String, String>();
        String factualString;
        if (sb.toString().contains("https://location.wfxtriggers.com")) {
          String factualreq =
              sb.toString().substring(sb.toString().lastIndexOf("WFX triggers Response {"));
          String factualreq1 =
              factualreq.substring(factualreq.indexOf("(") + 1, factualreq.indexOf(");") - 1);
          //	String[] arrays = Lotamereq.split(";");
          System.out.println("FactualReq1 ::" + factualreq1);

          //	System.out.println("json is :;"+Lotamereq1);
          String[] factualarrays = factualreq1.split("},");
          //	System.out.println("Lotamearray is::"+ Lotamearrays.toString());
          // Gson gson = new Gson();
          String[] factualVal = null;

          for (String factualKeys : factualarrays) {
            // System.out.println("Lotkeys ::"+LotKeys.toString());
            factualVal = factualKeys.split(";");

            for (String FactualValues : factualVal) {
              if (FactualValues.contains("index")) {
                String Factualval = FactualValues.toString().replace("{", "").trim();
                System.out.println("Factual values are ::" + Factualval);

                if (Factualval.contains("")) {
                  Assert.assertNotNull(Factualval);
                } else {

                  container.add(
                      Factualval.toString().replaceAll("index =", "").trim().replaceAll(", ", ","));
                }
              }
            }
          }
          // System.out.println("sg values are :" + sg.toString());
          String Actual = fgeoval.toString().replace("[", "").replace("]", "");

          System.out.println("fgeoval  ::" + Actual.toString());

          // System.out.println("Container vales are :"+container.toString());
          String Expected = container.toString().replace("[", "").replace("]", "");
          System.out.println("Container vales are ::" + Expected.toString());

          // Assert.assertEquals(Actual, Expected);

          String[] Factualarrays = Actual.split(",");
          System.out.println("Verifing the " + Factualarrays);
          for (String Factualkey : Factualarrays) {
            System.out.println(Factualkey);
            if (Expected.toString().contains(Factualkey.toString())) {

              System.out.println("Values are matched");
              ATUReports.add("FGEO value is present", false);
              logger.log(LogStatus.PASS, "FGEO Values are matched");
            } else {
              FactSteps = FactSteps + 1;
              System.out.println("Values are not matched");
              Assert.fail();
            }
          }
        }
      }
      br.close();

    } catch (Exception e) {
      e.printStackTrace();
    }

    System.out.println("Verification of FactualCall test case done");

    reporter.endTest(logger);
    reporter.flush();
  }
Beispiel #12
0
  @Test
  public void loginInvalidPass()
      throws IOException, InterruptedException, ClassNotFoundException, SQLException {
    System.setProperty("newlogfile.name", "GQM_2");
    String className = this.getClass().getSimpleName();
    System.out.println(className);
    Properties properties = new Properties();
    FileInputStream fis =
        new FileInputStream("C:\\GQMaps_workspace\\xsltfinGQMaps\\globalProperties.properties");
    properties.load(fis);
    if (properties.getProperty("mode").equalsIgnoreCase("grid")
        && properties.getProperty("browser").equalsIgnoreCase("firefox")) {

      driver = new FirefoxDriver();
    }
    ExtentReports extent = ExtentReportManager.getInstance();
    ExtentTest test;
    Logger logger = Logger.getLogger("GQM_2");
    PropertyConfigurator.configure("log4j.properties");
    // NewLogForEachRunFileAppender nfl =new NewLogForEachRunFileAppender();
    // nfl.setFile(className);

    test = extent.startTest("GQM_2", "monitoring check in GQMaps");

    driver.manage().deleteAllCookies();
    File file = new File(properties.getProperty("excelSheetsPath") + "\\LoginModuleData.xlsx");
    String username = null, password = null, asset_id = null, date = null;
    ResultSet res = DBConnection("GQM_2");
    while (res.next()) {
      username = res.getString("username");
      System.out.println(username);
      password = res.getString("password");
      System.out.println(password);
      asset_id = res.getString("assetid");
      System.out.println(asset_id);
      date = res.getString("date");
      System.out.println(date);
    }
    test.log(LogStatus.INFO, "Launching GQMaps");
    driver.get(" http://52.74.175.175:8080/GQMapsCustomerUI/");
    logger.info("launching GQMaps");
    if (driver.findElement(By.xpath(".//*[@id='txtUserId']")).isDisplayed()) {
      driver.findElement(By.xpath(".//*[@id='txtUserId']")).sendKeys(username);
      logger.info("username web element is present-passed");
      test.log(LogStatus.PASS, "Verifying username present", "username web element is present");
    } else {
      test.log(LogStatus.FAIL, "Verifying username present", "username web element is not present");
      logger.error("username web element is not present");
    }

    if (driver.findElement(By.xpath(".//*[@id='pwdPassword']")).isDisplayed()) {
      driver.findElement(By.xpath(".//*[@id='pwdPassword']")).sendKeys(password);
      logger.info("password web element is present-passed");
      test.log(LogStatus.PASS, "Verifying password present", "password web element is present");
    } else {
      test.log(LogStatus.FAIL, "Verifying password present", "password web element is not present");
      logger.error("password web element is not present");
    }

    // driver.findElement(By.xpath(".//*[@id='pwdPassword']")).sendKeys(password);
    driver.findElement(By.xpath(".//*[@id='submitLogin']")).click();
    // Thread.sleep(1000);
    try {
      driver.findElement(By.xpath(".//*[@id='cmbGoals']/li[2]/a")).click();
      logger.info("monitoring web element is present-passed");
      test.log(LogStatus.PASS, "Verifying Monitoring present", "monitoring web element is present");
    } catch (Exception e) {
      test.log(LogStatus.FAIL, "Verifying monitoring present", e.toString());
      logger.error("monitoring web element is not present");
      File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
      // Now you can do whatever you need to do with it, for example copy somewhere
      FileUtils.copyFile(
          scrFile,
          new File(
              "C:\\GQMaps_workspace\\xsltfinGQMaps\\ExtentReports\\Screenshots\\screenshot.png"));
      test.addScreenCapture(
          "C:\\GQMaps_workspace\\xsltfinGQMaps\\ExtentReports\\Screenshots\\screenshot.png");
    }
    // driver.findElement(By.xpath(".//*[@id='cmbGoals']/li[2]/a")).click();
    try {
      driver.findElement(By.xpath(".//*[@id='AssetId']")).sendKeys(asset_id);
      logger.info("asset_id webelement is present");
    } catch (Exception e) {
      logger.error("asset_id web element is not present");
    }
    driver.findElement(By.xpath(".//*[@id='Date']")).sendKeys(date);
    driver.findElement(By.xpath(".//*[@id='btnAsset']")).click();
    driver.close();
    driver.quit();
    extent.endTest(test);
    extent.flush();
  }
  @AfterTest
  public void afterTest() {

    driver.quit();
    extent.endTest();
  }
 @Test
 public void test2() {
   extent.startTest("Test2", "it is second test");
   extent.log(LogStatus.INFO, "second test case");
 }
 @BeforeTest
 public void beforeTest() {
   extent.init("TestNGBasicSample.html", true);
   SeleniumDriver selenium = new SeleniumDriver();
   driver = selenium.initializeDriver();
 }