21 Aralık 2017 Perşembe

Selenium TakesScreenshot Arayüzü

getScreenShotAs metodu
Örnek
Şöyle yaparız.
WebDriver driver = new FirefoxDriver();

driver.get("http://www.google.com/");

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:\\tmp\\screenshot.png"));
Örnek
Şöyle yaparız.
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
driver.manage().window().maximize();

TakesScreenshot scrShot =((TakesScreenshot)driver);

//Call getScreenshotAs method to create image file
File srcFile = scrShot.getScreenshotAs(OutputType.FILE);

//Move image file to new destination
File destFile = new File("C:\\shot.png");

//Copy file at destination
FileUtils.copyFile(srcFile,destFile);

Selenium

ChromeOptions Sınıfı
add_arguments metodu
Örnek
Şöyle yaparız.
ChromeOptions option = ChromeOptions();
option.add_arguments("--start-maximized");
Örnek
Şöyle yaparız.
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-gpu");
options.addArguments("--disable-extensions");
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("--window-size=1920,1080");
options.merge(seleniumCapabilities);
driver = new ChromeDriver(options);
TakeScreenShot Arayüzü
Selenium TakeScrenShot Arayüzü yazısına taşıdım.

WebDriver Arayüzü
Selenium WebDriver Arayüzü yazısına taşıdım.

WebDriverWait Sınıfı
Selenium WebDriverWait Sınıfı yazısına taşıdım.

WebElement Arayüzü
Selenium WebElement Arayüzü yazısına taşıdım.

POI Word İçin XWPFRun Sınıfı

Giriş
Şu satırı dahil ederiz.
import org.apache.poi.xwpf.usermodel.XWPRun;
addPicture metodu
Şöyle yaparız.
InputStream pic = new FileInputStream("C:\\test.png");
run.addPicture(pic, Document.PICTURE_TYPE_PNG, "3", 0, 0);
getCTR metodu
Şu satırı dahil ederiz.
import org.apache.xmlbeans.XmlObject;
XmlObject nesnesi döner. Şöyle yaparız.
XWPFRun run = ...;
String declareNameSpaces = "declare namespace w='http://schemas.openxmlformats.org/...';"
+ "declare namespace wp='http://schemas.openxmlformats.org/...'; "
+ "declare namespace a='http://schemas.openxmlformats.org/...'; "
+ "declare namespace pic='http://schemas.openxmlformats.org/...'; "
+ "declare namespace r='http://schemas.openxmlformats.org/...' ";

XmlObject[] selectedObjects = run.getCTR().selectPath(
  declareNameSpaces
+ ".//w:drawing/wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/@r:embed");
if (selectedObjects.length > 0) {
  String rID = selectedObjects[0].newCursor().getTextValue();
}
setText metodu
Şöyle yaparız.
XWPFParagraph par = docx.createParagraph();
XWPFRun run = par.createRun();
run.setText("Hello, World."); 

POI Word İçin XWPFParagraph Sınıfı

Giriş
Şu satırı dahil ederiz.
import org.apache.poi.xwpf.usermodel.XWPParagraph;
constructor
Şöyle yaparız.
XWPFDocument document = new XWPFDocument(new FileInputStream("WordInsertPictures.docx"));
for (XWPFParagraph paragraph : document.getParagraphs()) {
  ...
}
createRun metodu
Dosyaya yazarken kullanırız. Şöyle yaparız.
XWPFParagraph par = docx.createParagraph();
XWPFRun run = par.createRun();
getRuns metodu
Şöyle yaparız.
for (XWPFParagraph paragraph : document.getParagraphs()) {
  for (XWPFRun run : paragraph.getRuns()) {
    ...
  }
}
getStyle metodu
Şöyle yaparız
String str = ...
XWPFParagraph paragraph = ...;
if (paragraph.getStyle().equals(str)) {...}