如何针对docker selenium和本地应用程序进行本地服务器运行的nightwatch测试?

时间:2017-04-20 10:54:40

标签: selenium docker nightwatch.js

Nightwatch

nightwatch --version

public class MyTask extends AsyncTask<Void, Integer, String>  {

    private View rootView;

    public MyTask(View rootView) {

        this.rootView = rootView;
    }

    @Override
    protected void onPostExecute(String result) {

        textView.setText(result);
        button.setEnabled(true);

        progressDialog.hide();

        Snackbar snackbar;
        snackbar = Snackbar.make(rootView, "Download Complete", Snackbar.LENGTH_LONG);
        snackbar.show();
    }
}

配置

 v0.9.14 

泊坞

图片

{
    "src_folders": [
        "test/e2e"
    ],
    "selenium": {
        "start_process": false,
        "port": 4444
    },
    "test_settings": {
        "default": {
            "launch_url": "http://localhost:8080",
            "selenium_port": 4444,
            "selenium_host": "172.17.0.2",
            "silent": true
        },
        "dev": {
            "desiredCapabilities": {
                "browserName": "chrome"
            },
            "globals": {
                "baseUrl": "http://localhost:8080/"
            }
        }
    }
}

网络

$ docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                     NAMES
8afbc5b1ee50        selenium/standalone-chrome   "/opt/bin/entry_po..."   25 minutes ago      Up 25 minutes       0.0.0.0:32770->4444/tcp   nightwatch-server

测试

$ docker inspect nightwatch-server  --format "{{ json .NetworkSettings.Networks }}" | python -m json.tool
{                                                                                                                                                                                                                                                "bridge": {                                                                                                                                                                                                                                      "Aliases": null,
        "EndpointID": "7e621587f6ecbaa9b9d73aee601f647bebd76346b16d9d88e27c8ac7671e503d",
        "Gateway": "172.17.0.1",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "IPAMConfig": null,
        "IPAddress": "172.17.0.2",
        "IPPrefixLen": 16,                                                                                                                                                                                                                           "IPv6Gateway": "",
        "Links": null,
        "MacAddress": "02:42:ac:11:00:02",
        "NetworkID": "363882b98acd8d8fb0756a296610a0135e3ebde4feae8bdceaa7917939d79752"
    }
}

结果

module.exports = {
    'index page': function (client) {
        client
            .url('http://localhost:8080')
            .waitForElementVisible('body', 1000)
            .assert.title('Google')
            .end();
    }
};

问题

为什么我无法访问本地服务器?

0 个答案:

没有答案