我有这样的输入
package rough;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.GregorianCalendar;
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.firefox.FirefoxDriver;
public class TestEmailAndScreenshot1 {
public static WebDriver dr;
public static String mailscreenshotpath;
public static void captureScreenshot(){
Calendar cal = new GregorianCalendar();
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
int sec = cal.get(Calendar.SECOND);
int min = cal.get(Calendar.MINUTE);
int date = cal.get(Calendar.DATE);
int day = cal.get(Calendar.HOUR_OF_DAY);
File scrFile = ((TakesScreenshot)dr).getScreenshotAs(OutputType.FILE);
try {
mailscreenshotpath = System.getProperty("user.dir")+"\\screenshot\\"+year+"_"+date+"_"+(month+1)+"_"+day+"_"+min+"_" +sec+".jpeg";
FileUtils.copyFile(scrFile, new File(mailscreenshotpath));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
WebDriver dr=new FirefoxDriver();
dr.manage().window().maximize();
dr.manage().timeouts().implicitlyWait(10L, TimeUnit.SECONDS);
dr.get("http://gmail.com");
dr.findElement(By.id("Email")).sendKeys("vijenderchhoker92");
captureScreenshot();
System.out.println(" Screenshot taken successfully....");
}
}
并且想要提取两个十六进制值,以便它们可以在Makefile中使用。
我该怎么做?
答案 0 :(得分:1)
您可以使用以下方法删除这两个值周围的所有内容:
./configure --enable-https=no
测试:
sed 's/.*<\(.*\)>.*/\1/'
如果需要将值取消引用变量:
% echo 'field = <0xaaa 0xbbb>;' | sed 's/.*<\(.*\)>.*/\1/'
0xaaa 0xbbb