is it possible to extract data from PDF when the URL is Query string on selenium webdriver
my URL would be www.test.com/PDFFile/GeneratePDF?queryString=PWTBxi3jD0330OuqnuaNT
my scenario is i wanna click on a link when opens up the pdf, read pdf and close the tab.below is my code
ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
System.out.println("No. of tabs: " + tabs.size());
driver.switchTo().window(tabs.get(1));
System.out.println(driver.getCurrentUrl());
URL url = new URL(driver.getCurrentUrl());
InputStream is = url.openStream();
BufferedInputStream fileToParse = new BufferedInputStream(is);
PDDocument document = null;
try {
document = PDDocument.load(fileToParse);
output = new PDFTextStripper().getText(document);
} finally {
if (document != null) {
document.close();
}
fileToParse.close();
is.close();
}
words = output.split("\n");
return words;
the code throws error as java.io.IOException: Server returned HTTP response code: 500 for URL: http://www.test.com/PDFFile/GeneratePDF?queryString=PWTBxi3jD0330OuqnuaNT at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at java.net.URL.openStream(URL.java:1045)
at com.hmids.utilities.PDFDataExtractor.readPDFInURL(PDFDataExtractor.java:37)
how to handle this
java selenium pdfbox
add a comment |
my URL would be www.test.com/PDFFile/GeneratePDF?queryString=PWTBxi3jD0330OuqnuaNT
my scenario is i wanna click on a link when opens up the pdf, read pdf and close the tab.below is my code
ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
System.out.println("No. of tabs: " + tabs.size());
driver.switchTo().window(tabs.get(1));
System.out.println(driver.getCurrentUrl());
URL url = new URL(driver.getCurrentUrl());
InputStream is = url.openStream();
BufferedInputStream fileToParse = new BufferedInputStream(is);
PDDocument document = null;
try {
document = PDDocument.load(fileToParse);
output = new PDFTextStripper().getText(document);
} finally {
if (document != null) {
document.close();
}
fileToParse.close();
is.close();
}
words = output.split("\n");
return words;
the code throws error as java.io.IOException: Server returned HTTP response code: 500 for URL: http://www.test.com/PDFFile/GeneratePDF?queryString=PWTBxi3jD0330OuqnuaNT at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at java.net.URL.openStream(URL.java:1045)
at com.hmids.utilities.PDFDataExtractor.readPDFInURL(PDFDataExtractor.java:37)
how to handle this
java selenium pdfbox
HTTP error 500 is a server error. This has nothing to do with PDFBox.
– Tilman Hausherr
Nov 21 '18 at 16:27
add a comment |
my URL would be www.test.com/PDFFile/GeneratePDF?queryString=PWTBxi3jD0330OuqnuaNT
my scenario is i wanna click on a link when opens up the pdf, read pdf and close the tab.below is my code
ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
System.out.println("No. of tabs: " + tabs.size());
driver.switchTo().window(tabs.get(1));
System.out.println(driver.getCurrentUrl());
URL url = new URL(driver.getCurrentUrl());
InputStream is = url.openStream();
BufferedInputStream fileToParse = new BufferedInputStream(is);
PDDocument document = null;
try {
document = PDDocument.load(fileToParse);
output = new PDFTextStripper().getText(document);
} finally {
if (document != null) {
document.close();
}
fileToParse.close();
is.close();
}
words = output.split("\n");
return words;
the code throws error as java.io.IOException: Server returned HTTP response code: 500 for URL: http://www.test.com/PDFFile/GeneratePDF?queryString=PWTBxi3jD0330OuqnuaNT at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at java.net.URL.openStream(URL.java:1045)
at com.hmids.utilities.PDFDataExtractor.readPDFInURL(PDFDataExtractor.java:37)
how to handle this
java selenium pdfbox
my URL would be www.test.com/PDFFile/GeneratePDF?queryString=PWTBxi3jD0330OuqnuaNT
my scenario is i wanna click on a link when opens up the pdf, read pdf and close the tab.below is my code
ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
System.out.println("No. of tabs: " + tabs.size());
driver.switchTo().window(tabs.get(1));
System.out.println(driver.getCurrentUrl());
URL url = new URL(driver.getCurrentUrl());
InputStream is = url.openStream();
BufferedInputStream fileToParse = new BufferedInputStream(is);
PDDocument document = null;
try {
document = PDDocument.load(fileToParse);
output = new PDFTextStripper().getText(document);
} finally {
if (document != null) {
document.close();
}
fileToParse.close();
is.close();
}
words = output.split("\n");
return words;
the code throws error as java.io.IOException: Server returned HTTP response code: 500 for URL: http://www.test.com/PDFFile/GeneratePDF?queryString=PWTBxi3jD0330OuqnuaNT at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at java.net.URL.openStream(URL.java:1045)
at com.hmids.utilities.PDFDataExtractor.readPDFInURL(PDFDataExtractor.java:37)
how to handle this
java selenium pdfbox
java selenium pdfbox
edited Nov 21 '18 at 14:04
Shlomi Bazel
14410
14410
asked Nov 21 '18 at 13:02
RengarajanRengarajan
62
62
HTTP error 500 is a server error. This has nothing to do with PDFBox.
– Tilman Hausherr
Nov 21 '18 at 16:27
add a comment |
HTTP error 500 is a server error. This has nothing to do with PDFBox.
– Tilman Hausherr
Nov 21 '18 at 16:27
HTTP error 500 is a server error. This has nothing to do with PDFBox.
– Tilman Hausherr
Nov 21 '18 at 16:27
HTTP error 500 is a server error. This has nothing to do with PDFBox.
– Tilman Hausherr
Nov 21 '18 at 16:27
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412643%2fis-it-possible-to-extract-data-from-pdf-when-the-url-is-query-string-on-selenium%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412643%2fis-it-possible-to-extract-data-from-pdf-when-the-url-is-query-string-on-selenium%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
HTTP error 500 is a server error. This has nothing to do with PDFBox.
– Tilman Hausherr
Nov 21 '18 at 16:27