如何在selenium驱动程序中读取xml文件

时间:2016-09-26 06:32:13

标签: java xml selenium-webdriver

我想用Selenium

阅读这个xml
<?xml version="1.0" encoding="utf-8"?> 
    <client name="eLife"> <site>qa.elife.dev.cms30.kriyadocs.com/welcome</site>; 
        <xpath> 
           <publication> </publication> 
           <Article>in progress</Article> 
           <Striking>Image></Striking> 
           <Upload>Digest</Upload> <Upload>sub article</Upload> 
           <Detailed></Detailed> 
        </xpath> 
    </client> 

代码段:

System.setProperty("webdriver.chrome.driver", "/home/administrator/Downloads/chromedriver");
WebDriver driver = new ChromeDriver();
String URL = "http://localhost/config.xml";
String course = driver.findElement(((WebElement) By.xpath(".//*[@id='pass-nodes-list']/li/div[2]/a")).getText());

1 个答案:

答案 0 :(得分:0)

不要这样做。使用XML解析器加载和解析XML。从XML获取所需数据后,将其传递给Selenium。使用正确的工具完成工作,您将获得更好的结果。