HI David,

Have you followed the instruction of resources below?
https://github.com/crosswalk-project/crosswalk-website/wiki/Crosswalk-WebDriver

1. Build XwalkDriver by building the 'xwalkdriver' target and get an executable 
binary in the build folder named 'xwalkdriver'.(Details referred to 
../README.md). You can get it from 
https://github.com/crosswalk-project/crosswalk-web-driver/tree/master/bin
2. Get Crosswalk for Android from Download page 
https://download.01.org/crosswalk/releases/crosswalk/android
3. Pakage your app by execute command
python make_apk.py --package=`package_name` --manifest=`manifest_file` 
--arch=`device_architecture` --enable-remote-debugging
4. Install your apk to device.
5. Install Selenium package by executing command
pip install selenium
6. Run xwalkdriver binary you get from step 1 on host
$./xwalkdriver
7. Execute following commands to test:
$ python
>>> from selenium import webdriver
>>> capabilities = {
  'xwalkOptions': {
    'androidPackage': 'YOUR_PACKAGE_NAME',
    'androidActivity': '.YOUR_ACTIVITY_NAME',
    'adb-port': 5037(default option if not selected),
  }
}
>>> driver = webdriver.Remote('http://localhost:9515', capabilities)
>>> driver.save_screenshot("screenshot.png")
>>> driver.title
>>> driver.quit()

You may need to remote debug Crosswalk Apps in Chrome developer tools as well: 
https://github.com/crosswalk-project/crosswalk-website/wiki/Remote-Debugging-on-Android

1. Install the webapp (enabled --enable-remote-debugging) on the device and 
launch it.
2. Open Chrome Browser in the host machine and input "chrome://inspect" in the 
address bar
3. App will be listed in the inspection page. Click to the button 'inspect' to 
inspect it
4. Check the element tab of Chrome dev tool.

Before debugging your Crosswalk app, make sure the right Google Chrome version 
is installed on your host, basically the Chrome version should be >= the second 
number of Crosswalk version, e.g. beta 13.42.319.7, the second number (42 in 
the above example) represents the upstream Chromium beta release version that 
the source is based on.

Crosswalk Release

Chromium/Chrome Version

12

41

13

42

14

43

15

44



BR
Belem

From: Crosswalk-help 
[mailto:[email protected]] On Behalf Of David 
Charbonnier
Sent: Thursday, April 23, 2015 8:15 AM
To: Alexander Biemann
Cc: [email protected]
Subject: Re: [Crosswalk-help] Webdriver setup


Thanks for this amazing detailed answer. But we already use and integrate xwalk 
and I agree its an essential project for android.
But I'm lost on automated testing with webdriver not the use of crosswalk.
On Apr 22, 2015 5:06 PM, "Alexander Biemann" 
<[email protected]<mailto:[email protected]>> wrote:
David,

This is what I have done for Android ...

OVERVIEW

1) In Android Studio, start a new project and have the XWalkView download as a 
dependency
2) Create a blank Activity with a RelativeLayout that fills the screen. Give it 
an ID.
3) Programmatically instantiate XWalkView and add it to the RelativeLayout
4) Load the HTML

It's an easy overview - but in practice about a day's work because 
https://crosswalk-project.org/documentation/embedding_crosswalk.html seems 
outdated.

DETAILS

1) update the build.gradle in your project to look like :

buildscript {
    repositories {
        jcenter()
        maven {
            url 
'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}
apply plugin: 'com.android.application'

repositories {
    jcenter()
    maven {
        url 
'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
    }
}

android {
    compileSdkVersion 21
    buildToolsVersion '22.0.1'
    defaultConfig {
        applicationId "com.my.android.project"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.1"
        multiDexEnabled true
    }
    dexOptions {
        jumboMode = true
        incremental true
        javaMaxHeapSize "2048M"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro<http://proguard-rules.pro>'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    releaseCompile project(path: ':YOURPROJECTFOLDER', configuration: 'release')
    debugCompile project(path: ':YOURPROJECTFOLDER', configuration: 'debug')
    // Needed to overcome the 64K Methods limit
    compile 'com.android.support:multidex:1.0.0'
}


2) XML and Programmatic Instantiation - this is necessary due to the XWalkView 
constructor having a bug :

Bug details ... see below, the context is cast to an Activity... this totally 
breaks it for XML instantiation


public XWalkViewInternal(Context context, AttributeSet attrs) {

    super(convertContext(context), attrs);



    checkThreadSafety();

    mActivity = (Activity) context;

    mContext = getContext();

    init(mContext, attrs);

}

So the "manual way" around it is ...

        <RelativeLayout
            android:id="@+id/id_xwalkview"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </RelativeLayout>

3) Java Code

        mContainer = (RelativeLayout) findViewById(R.id.id_xwalkview);
        mWebView = new XWalkView(mParentActivity, mParentActivity);
        RelativeLayout.LayoutParams relativeParams = new 
RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 
ViewGroup.LayoutParams.MATCH_PARENT);
        mContainer.addView(mWebView, relativeParams);


4) The final step is loading dynamically generated HTML

StringBuilder strHTML = new StringBuilder();
strHTML.append("<html><head></head><body>");
// add your HTML here
strHTML.append("</body></html>");
final String completeHTML = strHTML.toString();

// loading with XWalkView
mWebView.load(null, completeHTML);



That's all there's to it. LOL it took a day because all this useful information 
was not in one spot.
By the way, XWalkView is awesome for HTML5 compared to the ridiculously 
fragmented experience of WebView.


Alexander


________________________________
Date: Wed, 22 Apr 2015 15:29:13 -0700
From: [email protected]<mailto:[email protected]>
To: 
[email protected]<mailto:[email protected]>
Subject: [Crosswalk-help] Webdriver setup
Hello,

I'm trying run tests on an android device. I already have those tests running 
using webdriver.io<http://webdriver.io> on chrome using selenium.
Now I want to run those tests on a xwalk webview. I don't really have an 
'application' for that, I don't want to test an application but some 
dynamically injected html/js in a simple crosswalk webview.
I'm not a selenium expert and I'm lost, between selenium, webdriver, xwalk, 
xwalkwebdriver.
I manage to setup xwalkwebdriver and if I run the tests I get a blank page and 
an error.
I'm also able to run an existing application (org.xwalk.app.hello.world) on a 
device using correct capabilities but then I get

DevTools request: http://127.0.0.1:12074/json/version
DevTools request failed

Then obviously it fail.

I'm lost...
If somebody can give me an overview of the setup I need to do what I want, I 
will be able to try and to ask more precise questions if needed.

Thanx,
David

_______________________________________________ Crosswalk-help mailing list 
[email protected]<mailto:[email protected]>
 https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help
_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help

Reply via email to