我有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设置属性?
答案 0 :(得分:0)
chrome驱动程序路径不正确
<ChromeDriverPath>C://Automation/Selenium Driver/chromedriver.exe/</ChromeDriverPath>
应为<ChromeDriverPath>C:/Automation/Selenium Driver/chromedriver.exe</ChromeDriverPath>