Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Selenium by (7k points)

I tried using WebView for extracting data from html.  My issue is that it is completely keeps force closing my apps.

My class:

package com.myapp.webscraper;

import com.myapp.webscraper.AppConfig;

import android.os.Bundle;

import android.webkit.WebView;

import android.webkit.WebViewClient;

import android.webkit.WebChromeClient;

import android.support.v7.app.AppCompatActivity;

import android.widget.EditText;

import org.openqa.selenium.*;

import org.openqa.selenium.firefox.FirefoxDriver;

public class Analytics extends AppCompatActivity{

    AppConfig cfg = new AppConfig();

    //WebView Analytics = null;

    EditText console = null;

    @Override

    public void onCreate(Bundle l){

        super.onCreate(l);

        if(cfg.useDebug)

        {

            setContentView(R.layout.analytics_debug);

            String content = "Yellow";

            EditText output = (EditText) findViewById(R.id.debug_analytics_output);

            WebDriver driver = new FirefoxDriver();

            //driver.get("http://google.co.uk");

           // WebElement body = driver.findElement(By.cssSelector("body"));

           // String content = body.getText();

            output.setText(content);

        }

        else

        {

            setContentView(R.layout.analytics);

        }

        if(cfg.useDebug)

        {

            //console.setText(console.getText() + "\n[URL LOADED]: " + Analytics.getUrl() + "\n");

        }

        else

        {

        }

    }

}

1 Answer

0 votes
by (31.9k points)
edited by

The Selenium WebDriver is used for desktop web functional automation testing and in order to be used on the Android, you need to use Appium.

Want to learn Selenium, check out our Selenium training.

Learn Selenium automation testing with our comprehensive Selenium Tutorial and ace your next job interview with our Selenium Interview Questions!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...