ScAlAn

Run test in docker

To do that use next steps.

1. Create standalone chrome selenium server:

docker run -d -p 4444:4444 selenium/standalone-chrome

bash-3.2$ docker run -d -p 4444:4444 selenium/standalone-chrome
Unable to find image 'selenium/standalone-chrome:latest' locally
latest: Pulling from selenium/standalone-chrome
8aec416115fd: Pull complete
695f074e24e3: Pull complete
946d6c48c2a7: Pull complete
bc7277e579f0: Pull complete
2508cbcde94b: Pull complete
87f3935fea59: Pull complete
eec2af8fab00: Pull complete
4260b93cf923: Pull complete
0949e2c674ff: Pull complete
c055c1c292d8: Pull complete
ebc8bdfd17e5: Pull complete
fe411204c602: Pull complete
ca0fc8e30444: Pull complete
f86ce080d9e9: Pull complete
58fa63ecb260: Pull complete
6ac376cc61d8: Pull complete
f3f919ca336b: Pull complete
397f07646f34: Pull complete
c52f1a15e4bc: Pull complete
df2c0a2110ef: Pull complete
b7bc30a2bf97: Pull complete
91bc92a2abd1: Pull complete
Digest: sha256:ec4d788cb36301bdd5f6fc804e9f8da7b155de47799483ae69af84fd32042ffc
Status: Downloaded newer image for selenium/standalone-chrome:latest
769370265d831e54887f30960b02c57103e20a4f1d489c2841fe6fa97be1e776

2. Use it from Node js app:

test.js:
var webdriver = require("selenium-webdriver");

function createDriver() {
var driver = new webdriver.Builder()
.usingServer('http://localhost:4444/wd/hub')
.withCapabilities(webdriver.Capabilities.chrome())
.build();
driver.manage().timeouts().setScriptTimeout(10000);
return driver;
}

var driver = createDriver();
driver.get("http://scalan.com");

driver.getTitle().then(function (title) {
console.log(title);
});

driver.quit();

Commands:
npm install selenium-webdriver
bash-3.2$ npm install selenium-webdriver
/Users/alexsco/Dropbox/WorkDirectory/Ancestry/docker-test-chrome
└─┬ selenium-webdriver@3.0.1
├── adm-zip@0.4.7
├─┬ rimraf@2.5.4
│ └─┬ glob@7.1.1
│ ├── fs.realpath@1.0.0
│ ├─┬ inflight@1.0.6
│ │ └── wrappy@1.0.2
│ ├── inherits@2.0.3
│ ├─┬ minimatch@3.0.3
│ │ └─┬ brace-expansion@1.1.6
│ │ ├── balanced-match@0.4.2
│ │ └── concat-map@0.0.1
│ ├── once@1.4.0
│ └── path-is-absolute@1.0.1
├─┬ tmp@0.0.30
│ └── os-tmpdir@1.0.2
└─┬ xml2js@0.4.17
├── sax@1.2.2
└─┬ xmlbuilder@4.2.1
└── lodash@4.17.4

npm WARN enoent ENOENT: no such file or directory, open '/Users/alexsco/Dropbox/WorkDirectory/Ancestry/docker-test-chrome/package.json'
npm WARN docker-test-chrome No description
npm WARN docker-test-chrome No repository field.
npm WARN docker-test-chrome No README data
npm WARN docker-test-chrome No license field.

node test.js
bash-3.2$ node test.js
Home - ScAlAn

Leave a Reply

Your email address will not be published. Required fields are marked *