简体   繁体   中英

Selenium Web Driver on Android

I recently tried using WebView to extract data from html and ran into an infinite amount of problems, so after searching around I found a Full Library Called Selenium , which had lots of different browser drivers such as Mozilla, Chrome , IE and it also made the Requests cutting out the HTTPRequest part of the app , it also did the work of Parsing the HTML, as it had a built in HTML Parsing Library which was really functional, the Only problem thats is completely stopping me in my tracks is the Fact that it keeps force closing my apps, here is 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
        {

        }

    }

}

If this library wont run on Android can you recommend any replacements or libraries that will push me forward on my app, it is vital I get this done, Many thanks.

Selenium WebDriver is used for desktop web functional automation testing. In order to be used on Android (or even iOS) you will need to use Appium .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM