2016-03-15 63 views
0

直到現在我用我的本地桌面上的路徑,其中的圖像是物理存在:如何在intellij中引用圖像?

val addInvoiceScanButton: WebElement = driver.findElement(By.className("cloudinary-fileupload")) 
    addInvoiceScanButton.sendKeys("/Users/username/Desktop/111.png") 

現在,我加入了111.png圖像中的IntelliJ我的資源文件夾,現在我想知道怎麼做我把它稱爲我的照片在桌面..?

感謝

+0

我不認爲這個問題與IntelliJ有什麼關係? – Ben

+0

你對,編輯 – Joe

回答

1

您可以使用好老的Java API來找到完整的路徑資源文件:

val filePath: String = this.getClass.getClassLoader.getResource("111.png").getFile 

再像以前一樣繼續:

addInvoiceScanButton.sendKeys(filePath)