How to download a file in IE10 using selenium webdriver? [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am trying to download a file using selenium webdriver but the test stops as soon as it encounters the IE10 download dialog box. How do I click save on this dialog box? Will Robot API help?

The short answer: This has been asked many times, please search.
The long and more correct answer: As of now (2013/10), it can't be done via WebDriver. It's one of the most requested features for the Selenium project.
You can try one of these things:
Make a request for the specified link using HttpURLConnection or Apache HttpComponents. You can even download the file this way, although the usual practice is just to assert a 200 OK response to make sure that the file can be downloaded (since you usually don't really need the file when you're testing your application).
Snatch the file using any Java approach. Or this tool made by someone to be used with Selenium.
Use the Robot class to simply press Down arrow and Enter or something. But beware, this will only work for your particular browser and OS. It will most likely break on any other configuration.

Related

how can i get data from a site [duplicate]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to scrape my website and then use the data from the website to populate elements in my app, my website has login pages and certain pages only open after the login has been done.
I started working with HtmlUnit as it is a headless browser and completed the custom api in a java IDE, later i tried to use the jar i generated from the java IDE and found that there are incompatibility issues with HtmlUnit and Android.
Can anyone propose a solution to this problem?
Edit :
Since no one actually answered this question I am currently going with a work around using android's native WebView, settings its Visibility to invisible and then using javascript interfacing to a Java object, I can inject JS code to scrape any data.
Use Jsoup library for such purpose. Very handy and easy to use.
Start with this answer and follow documents and other examples.
Either you contribute to HtmlUnit to produce a version of HtmlUnit not using the missing dependencies from Android.
Or you can use an alternative method like this one, as this seems to be the path someone else go before you.
If a real headless browser able to manage any recent web features, would exist, it would mean a team would have developed it and then invest much effort in it (in supporting existing and coming features) consistently.
Apart from Opera, Chrome, IE, and Firefox browsers, there is no such team.
I would point out Chromium (CEF) as the most open and actively supported cross language wise. Try Cef for java

Download and read web source code, illegal? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I am working on a project which generates a meaningful url, connects to it, and download its HTML source code. The program will further read the source and extracts useful info from it. Is this illegal?
By itself, there is nothing illegal happening from what you've described. But you're being very vague.
What do you mean by "generates a meaningful url"? Generates how? What determines "meaningful"?
Downloading the html given by the server at the requested url is exactly what a browser does. Nothing odd there. Browsers also read that html and build a document from it to display to a user.
What do you mean by "extracts useful info from it"?
What do you do with the resulting info?
Are you bypassing any security, or spamming the same server with massive numbers of requests? Are you doing anything that violates someone's privacy? Are you reposting any of the information you gathered without referring back to its original source?
What is it about your project that is even raising a red flag in your mind about legality?
These are the sorts of questions you should be asking yourself.
If this is for a personal project, then no it is not illegal in the least. If this is for a commercial product, however, I would err on the side of respecting any copyrighted content on the webpage.

Can I run java code in html textbox? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I am writing one web page in which I am putting one html input type="textarea" in which user will write their java code and on submit it will return output of that java code. Can I do this using jsp? if not then what are the other ways.
I would think very carefully before allowing people to do that.
At the very least, to read and run the user's input, you will need a JDK to compile it, and a JVM to run it. Since you're talking about over the web, presumably the user's machine will not have those (otherwise they'd just use theirs), so you'd have to use the ones on your server - that is, take the user's text, upload it as a .java file to your server, compile and run it (for an anonymous user on your server!), and send the result back to the browser session.
As you can see, there are a couple of pretty big, bad security problems here. Not recommended !

Selenium webdriver: I was able click on a textbox but not able to send any text through sendKeys. for example email id textbox [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am not able to pass value in a text box through sendkeys() in selenium Webdriver(Java). But we can enter manually. I tried every thing xpath, cssSelector, id. Any ideas. Thanks in advance.
Please post code the code snippet and html source file.
Folowing can be reason :
The element you are tring to access can be in a frame.
In that case use driver.switchTo.frame("frame_name");
Check for browser settings in tools---> Internet options --> Security tab--> All the levels of security should be protected or non-protected.
Check if there is java vm plugin in your browser.
Check if browser zoom level is 100%. It affects mouse click

Making my computer prompt me with a predeterminedquestion whenever I open firefox [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm inspired by reading this from John Conway's wikipedia page:
http://en.wikipedia.org/wiki/John_Horton_Conway#Algorithmics
I want to have a window pop up whenever I open firefox to ask a question that I code. I'd type in a response in a text box and upon hitting return it would display the answer and whether I'm correct or not. What I'm thinking of right now would be I'd get a random number in centimeters between, say, 0 and 300 and I would try to get the correct amount of inches it corresponds to.
I have no idea how to even start going about this. How do you make some program execute when I click and turn on a browser? I have some experience with swing so perhaps we could use that but I've looked through some of the swing library to no avail. I put the java tag there because it's the language I'm most familiar with so a solution in java would be best if possible. Also, are there any good resources to learn how to do stuff like this?
I think my main problem is getting some prewritten code to run upon opening the browser. The rest I can probably deal with in swing but I'm not completely sure.
Lastly, sorry for the non-space between predetermined and question, but the site doesn't let me use the second word in the title even though it makes sense here.
this looks relevant
it talks about controlling web browsers, sounds like a tool for you
This question is borderline off-topic for SO, but not hard to answer and interesting enough to grab my attention so I'll go ahead and do so.
You'd have to code all of this yourself, but you could use InnoSetup (http://www.jrsoftware.org/isinfo.php) to create yourself an installable Java program and follow these directions to launch Firefox after you answer your predetermined question:
http://www.daniweb.com/software-development/java/threads/7710/how-to-run-external-.exe-programs-from-java

Categories

Resources