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

qjp7pelc  于 2023-01-07  发布在  Java
关注(0)|答案(1)|浏览(135)

我想使用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());
2hh7jdfx

2hh7jdfx1#

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

相关问题