如何在selenium中使用xml设置属性?

时间:2017-09-28 19:10:58

标签: xml selenium

我有xml:

<?xml version="1.0" encoding="utf-8" ?>
<Enviroment>
<BrowserType>chrome</BrowserType>
<URL>https://dev.leolane.com/</URL>
<ChromeDriverPath>C://Automation/Selenium Driver/chromedriver.exe/</ChromeDriverPath>


<!--Report -->
<ReportFilePath>C:/Automation/Reports/</ReportFilePath>
<ReportFileName>TestReport.html</ReportFileName>
</Environment>

我想在我的代码中使用驱动程序路径

我的代码是:

@BeforeClass

public static void  startsSession() throws ParserConfigurationException, SAXException, IOException

{
    System.setProperties ("webdriver.chrome.driver");
    driver.get(getData("ChromeDriverPath"));
    driver = new ChromeDriver();
    driver.get(getData("URL"));

当我运行程序时,我得到空指针异常 如何使用xml设置属性?

1 个答案:

答案 0 :(得分:0)

chrome驱动程序路径不正确

<ChromeDriverPath>C://Automation/Selenium Driver/chromedriver.exe/</ChromeDriverPath>

应为<ChromeDriverPath>C:/Automation/Selenium Driver/chromedriver.exe</ChromeDriverPath>