ldino95 / Desafio-de-testes-automatizados-Yaman

Desafio de testes automatizados Yaman
0 stars 0 forks source link

Commons #1

Open ldino95 opened 6 years ago

ldino95 commented 6 years ago

package commons;

import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver;

public class OpenBrowser { //class public static WebDriver openFirefox(WebDriver driver){ //metodo

    driver = new FirefoxDriver();
    driver.get("https://www.mercadolivre.com.br");

    return driver;

} }

ldino95 commented 6 years ago

package commons;

import java.awt.AWTException; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException;

import javax.imageio.ImageIO;

import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement;

import ru.yandex.qatools.ashot.AShot; import ru.yandex.qatools.ashot.Screenshot;

public class Print { public static String PrintTela() throws AWTException, IOException {

    String format = "jpg";

    String savePathEvidence = "C:\\printtst";
    String titlePage = "nomePrint";

    Robot robot = new Robot();

    Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
    BufferedImage screenFullImage = robot.createScreenCapture(screenRect);

    ImageIO.write(screenFullImage, format, new File(savePathEvidence + "\\" + titlePage + ".jpg"));

    String pathEvidence = savePathEvidence + "\\" + titlePage + ".jpg";

    return pathEvidence;

}

public static String printElemento(WebDriver driver, String element) throws IOException {

    String savePathEvidence = "C:\\printtst";
    String titlePage = "Elemento";

    WebElement ele = driver.findElement(By.xpath(element));

  //  Screenshot screenshot2 = new AShot().takeScreenshot(driver,ele);

  //  ImageIO.write(screenshot2.getImage(),"PNG",new File(savePathEvidence + "/" + titlePage + ".png"));

    return null;
}

}

ldino95 commented 6 years ago

package commons;

public class StartFirefox {

public static void firefox() {
    System.setProperty("webdriver.gecko.driver" , "C:/geckodriver.exe");

}

}