将geckodriver置于资源中并将其映射在正在处理的计算机上,但不在任何其他计算机上。我需要它将它导出到其他机器,所以我创建一个我需要在任何其他机器上运行的jar,但是当在其他机器上运行jar时抛弃"驱动程序可执行文件的路径必须是由webdriver.gecko.driver系统属性设置"错误。
public static WebDriver createDriver()
{
WebDriver driver= new FirefoxDriver();
System.setProperty("webdriver.gecko.driver", "./src/main/resources/geckodriver");
driver = new FirefoxDriver(FirefoxDriverProfile());
driver.manage().window().maximize();
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
return driver;
[Please take a look at the image]
https://i.stack.imgur.com/khGBu.png
答案 0 :(得分:1)
您似乎错过了文件扩展名。 以下适用于我使用相对文件路径:
WebDriver driver= new FirefoxDriver();
System.setProperty("webdriver.gecko.driver", "./src/main/resources/geckodriver");
编辑:您是否尝试交换这两行的顺序? 除非我弄错了,否则应该在创建WebDriver之前设置系统属性。
System.setProperty("webdriver.gecko.driver", "./src/main/resources/geckodriver");
WebDriver driver= new FirefoxDriver();
应该是
for(key in splitedDataArray){
calculatePower(splitedDataArray[key]);
var octopusMAC = getOctopusIDFromRaw(splitedDataArray[key]);
var channelID = getChannelIDFromRaw(splitedDataArray[key]);
console.log("outside")
getChannelCTSize(octopusMAC, channelID, function (result) {
console.log("inside")
var timestamp = convertDateTimeToInt(transmission.date);
var adcTicks = getAdcTicksFromRaw(splitedDataArray[key]);
var power = convertAdcTicksToAmps(parseInt(adcTicks, 16), result);
console.log("channelID: " + channelID + " ADC ticks HEX: " + adcTicks + " timestamp: " + timestamp + " power for " + result + "A CT Size: " + power);
});
}
答案 1 :(得分:0)
您可以将其设置为: -
System.setProperty("webdriver.gecko.driver", new File("./src/main/resources/geckodriver").getCanonicalPath());