how to parse HTML in android and execute javascript - android

I am trying to figure out how to parse HTML where I should execute javascript.
I was trying a lot of way to do that, but still have nothing
For example:
HTMLUnit - seems to me like the best parser to execute javascript, but when I try to add dependencies getting error, that haven't solved in stackoverflow
Selenium Web Driver. Also looks good, but again a lot of problem with dependencies. And cannot find any examples of that
Rhino. Very limited documentation about integration in android
JSoup. Pretty good, but cannot execute javascript
I will be very thankful who will try me to figure out how to parse HTML with javascript with some examples. Thank you very much

You should think of using Appium to parse your HTML webpages on Android. Appium is an extension of Selenium Webdriver providing automation capabilities on Android and iOS.
You can get started from this link: How to setup Appium Environment for Android Automation?
Also, you can execute javascript using appium driver:
js = (JavascriptExecutor) driver;
js.executeScript("<JAVASCRIPT CODE>");

Related

using loadUrl()

It's been a few years since I've tried to create an Android application and since everything has moved away from Eclipse and now onto AS my old templates no longer work. I'm looking for tutorials that allow me to use my own custom html, css and Jquery, seeing as stuff like super.loadUrl("file:///android_asset/www/index.html"); don't seem to work anymore.
Are there any links or anything anyone can provide to get me started on creating non java dependant application?
If you want to make an app without using java you can start learning ionic framework https://ionicframework.com/
You can also go through Apache Cordova. It allows you to use standard web technologies such as HTML5, CSS3, and JavaScript for cross-platform development and you can also go with Xamarin that uses C# for cross-platform development.
You can also go through this tutorial for better understanding and for start learning from fresh :
Ionic tutorial https://www.youtube.com/watch?v=0jamhGf-8ww&list=PLYxzS__5yYQljbuGjaeugpqs9U07gS5P5
Cordova Tutorial https://www.youtube.com/watch?v=kqWZuEpHoSw&list=PLReL099Y5nRd9BNsMZwXvTDeqnfRMiGJy
Hope this will be helpful!!

Protractor and Appium using WD good idea?

We've built an app using Cordova. Automated tests are implemented using Protractor and Appium, followed this guide. This works OK, but I'm not sure if this is the best way. We run into some random failed tests.
Then I read this on the WebDriver Github site:
It is possible to use wd to test mobile devices using either Selenium or Appium. However in either case the full JsonWire protocol is not supported (or is buggy).
If I read this correctly, using WebDriver with Appium is buggy.
But even Appium has examples where they are using WebDriver, see here.
I'm not sure what the alternative is, maybe WebdriverIO? But I can't find much documentation about it. Or did I read it wrong, and should we be using wd without issues here?
In answer to your specific question, Protractor, Selendroid, and WebdriverIO (amongst others) are all JavaScript implementations of (Selenium 2.0) WebDriver - which is a layer/protocol/API through which you can query and control Appium. Bindings exist in all sorts of languages: python, Java, etc.
So, yes, it is perfectly possible to use Protractor and Appium together.
(I wouldn't personally, because I still associate Protractor with AngularJS applications, plus it is by no means the only game in town for JavaScript WebDriver. However, that is not down to bugs or lack of support.)
I'd definitely want to query the quote on Mr. Christian's site - which not the official WebDriver Github site by any means. It's not wrong, but the WebDriver spec is big, and hardly anyone implements all of it. So I'd take the statement with a pinch of salt.
Having established that your basic approach is not at all wrong, it would be good to explore your random failed tests, and to work out where the issues lie.
Certainly as far as newbies go, a very large proportion of "random" failures are completely avoidable race conditions within their test code, but even more experienced users will have to deal with the same problem in other forms.

Consuming a web service in Android [duplicate]

i am new to Android development
i have a web service made in php now i want to consume it in android can any one guide me how to achieve this..???
i have tried many code samples on net but failed to achieve this goal.
i am using Eclipse with ADT.
any help would be appriciated.
Kindly go through the following link. you will find code examples here
http://www.anddev.org/calling_a_web_service_from_android-t348.html
Android is developed using Java platform. what you should do is create a WebService and expose the WSDL via HTTP.
write your java program calling this Webservice.
its easier and simpler.

Calling webservice from javascript on android

How to call a webservice from javascript on android?
My html file is in assest/www folder.
so - you would like to call AJAX web service from the JavaScript in a web page? This is not dependent (or almost not) on the used web browser. The same JavaScript code will work on Android, iPhone or desktop browser.
For good AJAX tutorial see there: http://www.peachpit.com/articles/article.aspx?p=425820
BR
STeN
This will help you: What's the difference between JavaScript and Java? You can't run Javascript in an Android Application!

How to connect html to native using phonegap in android

i started working on android using phonegap. In iphone we use phoneGap.exec(classname.methodname, arguments) to connect to the native application from html. But how can you do it in Android? Can anyone help me in this please?
Thanks in advance,
Bharath gangupalli
Sounds like you're trying to connect to a native plugin. The technique is generally the same on Android, include the native code and then call out using the Phonegap.Exec() wrapper. If you're looking for a sample to start from try out the BarcodeScanner plugin, which includes native code and the JS wrapper to call out to it:
https://github.com/purplecabbage/phonegap-plugins/tree/master/Android/BarcodeScanner

Categories

Resources