I want to add a functionality in my app which submits a review of a place on the place's google plus account ..
As you might be knowing the format of the google plus page ..
It has a button "Write a review" (Which is not a button but a clickable 'div')
On pressing this button , a dialogue appears which has a field to write review , It is here i want to actually write the review through the code and press the submit button .
Please help me through this ..
How to achieve this thing ??
Jsoup parses HTML. It does not execute JavaScript or emulate a browser, so there's no dialog box for it to interact with.
You could try using a browser's network monitor feature (part of their developer tools) to see what requests are made when the dialog box is submitted, then simulate those requests from your application. You could also see if there's a Google+ API for submitting reviews other than from the place's Google+ page. APIs are easier to use, robust against changes in the web page's HTML, and don't risk violating terms of service that prohibit automation. Finally, you could try a browser automation tool (commonly used for unit testing web pages); I don't know of any for Android but I'd be surprised if there aren't any.
Related
In my app I have a webview to show the user some information from a web page. Before seeing the info though, you have to choose an option on a dropdown list on the webpage. Is there any way I can choose the right option for the user (via code) and only have them see the content?
You can run arbitrary javascript inside a WebView, initiated from Java. Be sure you have javascript enabled. Once you've done that,
theWebView.loadUrl( "javascript:alert('Hello')" );
is the mechanism to invoke javascript functions or scripts. To pre-select a drop-down, you may want to include jquery or such, making the selection easier.
i have some basic knowledge of java (made little programs to help everyday life) Now the thing is i want to make a program that posts offers on a site every 2-3 minutes. I have never done anything with java related to the internet and web pages and even after browsing the internet i am clueless. How would i go about setting up a connection to a certain page click a certain button on that page and then fill in 3 boxes with information and post the offer?
Here is what i have to click:
Here is the form i have to fill in:
You have to learn a bit more about how HTML form works, but basically browser sends a POST request to the webserver with the values from the form.
Chrome's Developer Tools, Firefox's web developer toolbar has a functionality what can help you to discover what request is sent to the server when you post a single form. Of course you have to fill the values with your heart content
If you already know what content you want to send, you can post it relative easily, it is described well with examples in this StackOverflow answer https://stackoverflow.com/a/4206094/182474.
But I strongly recommend to discover how browsers works internally from the aspect of HTTP protocol, because it is a very useful knowledge if you want to develop tools that interacts with web APIs or simulate posting HTML forms.
You could use java.awt.Robot class and make all this thinks =)
you only need to write your manually action to the automated action =)
move mouse on text
write this...
tab
write this other..
tab press enter
wait N second
hope it helps! =)
I am using robotium tool for wirting the test scripts for an application . I wanna know how do I handle the third party's webview(i.e, Login) in my application .
For example, if I have a button Checkout With Paypal and when I click on it i get a login page from Paypal third party, which asks for the following
Login ID:
Password:
Then how do click on the above to text boxes in the test script and enter the appropriate text in that.?
If the webview is external to your application then im afraid to tell you that when using robotium it will be impossible to test what you want. Robotium can only inject events into your applications process which this will sadly not be a part of.
If however it is within your application then you are (slightly) in luck. You can interac with the webview, however robotium currently does not have any way to interact with elements inside webviews. It is possible to do this though, you have to fire in javascript yourself to interact with the web page. This is a bit of a pain but products such as https://github.com/calabash/calabash-android do it nicely so you can look at their implementation.
There is a third option, get the developers to fake the section of the application for your tests. Then add in a test that runs on a version without the faking to check that the correct intent is fired using an intent filter, that should cover both bases.
I have little knowledge about web programming, and I was looking through a lot of examples which gives alot of examples about writing on the webpage for web browser to see, but nothing about getting request when user presses a button the webpage.
For example, upon opening the server, it opens the port 80, then I want to go to web browser and type "localhost:80" to access the webpage made by the server client. The webpage has a button which when I click it, webpage changes to something else like "Clicked!".
Can someone show me an example code of this? Link to an example would be great as well.
Thank you very much.
I would recommend using something like Apache's HttpClient to imitate a button press, which is just an HTTP POST. And if you don't want to use a third-party library, the standard Java library already rolls its own.
BACKGROUND
I'm doing an interactive art project for school.
PROCESS
For this project the last step is to go to a facebook fanpage and like the facebook page.
ASSUMPTIONS
I'll be using Java to open up a browser and then go to the facebook page. However, I would like to use something like one line of script to like the facebook fanpage.
PROBLEM
Is there will be no mouse for this interaction.
SOLUTIONS
Is there a script I (or stackoverflow) can write that I may execute that will like a facebook page?
Or is there any other solution that you guys can think of?
TOOLS/LANG. BEING USED: ARDUINO/JAVA, HTML, JAVASCRIPT and CSS.
You could use a browser automation framework like Selenium to load the Facebook page and simulate clicking on the Like button, but you would have to log the correct user in first. Selenium has a Java interface you could use.
Alternatively, if you are having it run on a single machine you control, you might have luck with doing some sort of userscript (something like this one) for the Facebook site so that when they are on the correct page, it clicks the Like button automatically. Then all you would have to do is launch the page from Java in the correct browser, and the userscript would do the rest. Note: Userscripts work on Firefox with GreaseMonkey installed, and on Chrome/Chromium without any extensions.
Make an application on Facebook and use their api to interact with the page: Facebook API
Alternatively, use some javascript to like the page once you navigate to it