1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
import * as path from "path";
import * as assert from "assert";
import TestServer from "./lib/TestServer";
import eventually from "./eventually";
import { Builder, Lanthan } from "lanthan";
import { WebDriver } from "selenium-webdriver";
import Page from "./lib/Page";
describe("tab test", () => {
const server = new TestServer().receiveContent(
"/",
`<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html>`
);
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async () => {
lanthan = await Builder.forBrowser("firefox")
.spyAddon(path.join(__dirname, ".."))
.build();
webdriver = lanthan.getWebDriver();
browser = lanthan.getWebExtBrowser();
await server.start();
browser = browser;
});
after(async () => {
await server.stop();
if (lanthan) {
await lanthan.quit();
}
});
it("repeats scroll 3-times", async () => {
const page = await Page.navigateTo(webdriver, server.url());
await page.sendKeys("3", "j");
const scrollY = await page.getScrollY();
assert.strictEqual(scrollY, 64 * 3);
});
it("repeats tab deletion 3-times", async () => {
const win = await browser.windows.create({ url: server.url("/#0") });
for (let i = 1; i < 5; ++i) {
await browser.tabs.create({
url: server.url("/#" + i),
windowId: win.id,
});
await webdriver.navigate().to(server.url("/#" + i));
}
const page = await Page.navigateTo(webdriver, server.url());
await page.sendKeys("3", "d");
await eventually(async () => {
const current = await browser.tabs.query({ windowId: win.id });
assert.strictEqual(current.length, 2);
});
});
});
|