Package test.old

Source Code of test.old.TestChromeDriver

package test.old;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class TestChromeDriver {
 
  static String url = System.getProperty("site", "http://www.google.com");

  static String os = System.getProperty("os", "linux");
  static String browser = System.getProperty("browser", "chrome");
  static String path = System.getProperty("path", "C:\\logs\\");
  static String filename = "screenshot_" + os + "_" + browser + ".png";
 
  public static void main(String args[]) {

    System.setProperty("webdriver.chrome.driver",
        "C:\\Titanium\\Titanium1\\lib\\chromedriver.exe");
   

    WebDriver driver = new ChromeDriver();

    // Google ����Ʈ �湮
    //driver.get(url);

    // ������ ����
    //System.out.println("Page title is: " + driver.getTitle());
    System.out.println("Filename: " + path + filename);

    //takeScreenShot(driver);
     
    try {
      scrapTest(driver);
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
   
    //driver.quit();
  }

  public static void takeScreenShot(WebDriver driver) {
    // ������ ����
    File scrFile = ((TakesScreenshot) driver)
        .getScreenshotAs(OutputType.FILE);
    try {
      FileUtils.copyFile(scrFile, new File(path + filename));
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 
  public static void scrapTest(WebDriver driver) throws FileNotFoundException {       
        // this its form more than 05 minutes without return
        try {
            long pollingForSecond = 1;
            long timeOutInSeconds = 999999;
            if(driver == null){ throw new Exception("Erro, driver informado era nulo");}
            String initialUrl = "https://www.zulutrade.com/";
            driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.HOURS);
            driver.manage().timeouts().setScriptTimeout(30, TimeUnit.HOURS);
            driver.get(initialUrl);
            driver.findElement(By.id("login-trigger")).click();
            driver.findElement(By.id("login-username")).sendKeys("DM472968");
            driver.findElement(By.id("login-password")).sendKeys("un3n5g");
           
            driver.findElement(By.id("btn-login")).click();
           
            Thread.sleep(5000);
           
            driver.findElement(By.linkText("������")).click();

            Thread.sleep(5000);
           
            String s =  driver.findElement(By.id("table-body-positions")).getText();
            System.out.println(s);
        while (true) {

            TableParser t = new TableParser(s);
            t.parse();
            SignalCreator sc = new SignalCreator(t.getZuluData());
            sc.createFile(path + "SIGNAL.CSV");
           
            driver.navigate().refresh();
            Thread.sleep(60000);
           
        }
          

        } catch (Exception ex) {
            //ConsoleHelper.printMessage("ERRO_ex:" + ex.getMessage(), new Date());
          ex.printStackTrace();
        }
    }
}
TOP

Related Classes of test.old.TestChromeDriver

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.