可能的方法:1)找到元素(地址)的正确css(或xPath)定位器2)然后使用从元素中获取内容(文本)
String cssSelecotr=..blablabla..
//1st way
String myAddress=driver.findELement(by.cssSelector(cssSelector)).getText();
//2nd way, using js executor
JavascriptExecutor js = (JavascriptExecutor) driver;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("var x = $(\""+cssSelecotr+"\");");
stringBuilder.append("return x.text().toString();") ;
String myAddress= (String) js.executeScript(stringBuilder.toString());
3)然后您可以为您的地址应用正则表达式(所有可见符号)
// myAddress ="100 RILEY DR\n AVONDALE,\n ARIZONA\n 85323-2004";
String myAdressEdited = myAddress.replaceAll("[^\\x20-\\x7E]+","");
希望这可以帮助