Archive For March 27, 2017

Run cmd command line on windows by java

By |

ProcessBuilder builder = new ProcessBuilder(“cmd.exe”, “/c”, “adb kill-server && adb start-server && adb devices”); builder.redirectErrorStream(true); Process p = builder.start();

Read more »

Save image in webdriver by java

By |

import java.awt.image.BufferedImage; import java.io.File; import java.net.URL;   WebElement imageEl = driver.findElement(By.xpath(“//img[@alt=’image’]”)); String imageElURL= imageEl .getAttribute(“src”); URL imageURL = new URL(imageElURL); BufferedImage saveImage = ImageIO.read(imageURL); ImageIO.write(saveImage, “png”, new File(“D:” + File.separator + “image.png”));

Read more »