我想使用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条答案
按热度按时间2hh7jdfx1#
不要这样做。用XML解析器加载并解析XML。从XML中获取所需数据后,将其传递给Selenium。使用正确的工具完成这项工作,您将获得更好的结果。