Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatible #11

Open
gogoyqj opened this issue Jun 28, 2017 · 1 comment
Open

compatible #11

gogoyqj opened this issue Jun 28, 2017 · 1 comment

Comments

@gogoyqj
Copy link
Owner

gogoyqj commented Jun 28, 2017

let webdriverio = require('webdriverio');
let client = webdriverio.remote({
    logLevel: 'verbose',
    // Using appium:
    port: 4723,
    desiredCapabilities: { // android QQ
        platformName: "Android",
        deviceName: "emulator-5554",
        platformVersion: "5.1",
        app: "com.tencent.mtt.x86",
        appActivity: "com.tencent.mtt.x86.MainActivity"
    },
    // desiredCapabilities: { // android default
    //     platformName: "Android",
    //     deviceName: "emulator-5554",
    //     platformVersion: "5.1",
    //     app: "com.android.browser",
    //     appActivity: ".BrowserActivity"
    // },
    // desiredCapabilities: { // android chrome
    //     browserName: 'chrome',
    //     platformName: "Android",
    //     deviceName: "emulator-5554",
    //     platformVersion: "5.1"
    // },
    // Using selenium standalone:
    // port: 4444,
    // desiredCapabilities: { // android mobile
    //     browserName: 'chrome',
    //     platformName: "Android",
    //     platformVersion: "5.1",
    //     deviceName: "emulator-5554",
    //     chromeOptions: {
    //         androidPackage: 'com.android.chrome'
    //     }
    // },
    // desiredCapabilities: { // android default: does not work in some situation
    //     chromeOptions: {
    //         androidPackage: 'com.android.browser',
    //         androidActivity: '.BrowserActivity',
    //         windowTypes: ['webview']
    //     },
    //     platformVersion: '5.1',
    //     browserName: 'chrome',
    //     deviceName: "emulator-5554",
    //     platformName: 'Android'
    // }
});
let browser = client
    .init();

browser.url('http://ued.qunar.com/hy2/yo/demo/src/html/component/scroller/lazyimage.html')
    .pause(5000) // webview app or browser wait for h5 ready for a time
    .contexts()
    .then(ctx => ctx, err => { return {flag: "using selenium standalone"}; })
    .then(ctx => {
        /**
         * Using appium:
         *  chrome: NATIVE_APP, CHROMIUM
         *  com.android.browser: NATIVE_APP, WEBVIEW_com.android.browser
         * Using selenium standalone:
         *  com.android.browser, com.android.chrome: throw Error
         */
        let webview = ctx.status === 0 && ctx.value[1];
        let flag = ctx.flag;
        if (webview || flag) return (flag ? browser : browser.context(webview))
                            .touchDown(20, 300)
                            .touchMove(20, 200)
                            .touchMove(20, 100)
                            .touchUp(20, 50);
        /**
         * com.tencent.mtt.x86: NATIVE_APP
         */
        return browser
                .touchAction([{
                    action: 'press', x: 20, y: 400
                },
                {
                    action: 'moveTo', x: 20, y: -200
                },
                {
                    action: 'moveTo', x: 20, y: -100
                },
                    'release'
                ]);
    })
    .then(() => {
        setTimeout(() => {
            browser.end();
        }, 5000);
    }, err => {
        console.log("err", err);
        setTimeout(() => {
            browser.end();
        }, 5000);
    });
@gogoyqj
Copy link
Owner Author

gogoyqj commented Jun 28, 2017

Using appium:

app: "com.android.browser",
appActivity: ".BrowserActivity",
app: "com.UCMobile",
app: "com.UCMobile.intl.x86",
appActivity: "com.uc.browser.InnerUCMobile",
appPackage: "com.tencent.mtt",
appActivity: "com.tencent.mtt.MainActivity",
app: "com.tencent.mtt.x86",
appActivity: "com.tencent.mtt.x86.MainActivity",
appPackage: 'com.android.browser',
appActivity: '.BrowserActivity',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant