Reputation: 125
I wanted to create a hyperlink using Apache POI and Java for Selenium Webdriver automation testing. But the thing is, when i'm creating a hyperlink using this code :
File file=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String screenshotLocation = "D:\\MyFolder\\Test Results\\Screenshots\\";
screenshotURL=screenshotLocation+datetimestamp+".png";
FileUtils.copyFile(file, new File(screenshotURL));
@SuppressWarnings("deprecation")
HSSFHyperlink link = (HSSFHyperlink)createHelper.createHyperlink(Hyperlink.LINK_FILE);
link.setAddress(screenshotURL);
hyperlinkList.add(link); // add all hyperlinks to an arraylist
createHyperlink
and LINK_FILE
are showing as deprecated
. Is there any alternate way to create hyperlink without deprecation? ( I've tried with XSSF also, but getting the same deprecation.)
FYI: when i'm using selenium-server-standalone-2.47.1.jar and poi-bin-3.17-beta1-20170701 , it is showing only the deprecation, not any error. But when i'm using updated version, for example Selenium-java-2.48.2.jar and poi-bin-3.17-20170915, along with the deprecation, one error message is showing: LINK_FILE cannot be resolved or is not a field.
Please Help. Thanks in advance.
Upvotes: 0
Views: 2881
Reputation: 69470
Hyperlink.LINK_FILE
is replaced by HyperlinkType.FILE
and the createHyperlink function was replaced by a new Funtion with the Parameter if type HyperlinkType
From the javadoc:
Hyperlink createHyperlink(int type)
Deprecated. POI 3.15 beta 3. Use createHyperlink(HyperlinkType) instead.
And
static int LINK_FILE Deprecated. POI 3.15 beta 3. Use HyperlinkType.FILE instead.
Upvotes: 2