aboutsummaryrefslogtreecommitdiff
path: root/e2e/completion_open.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'e2e/completion_open.test.js')
-rw-r--r--e2e/completion_open.test.js77
1 files changed, 39 insertions, 38 deletions
diff --git a/e2e/completion_open.test.js b/e2e/completion_open.test.js
index 5828768..b2b7484 100644
--- a/e2e/completion_open.test.js
+++ b/e2e/completion_open.test.js
@@ -4,10 +4,10 @@ const path = require('path');
const assert = require('assert');
const eventually = require('./eventually');
const settings = require('./settings');
+const { Builder } = require('lanthan');
+const { By, Key } = require('selenium-webdriver');
const Console = require('./lib/Console');
-const Key = lanthan.Key;
-
const newApp = () => {
let app = express();
@@ -23,20 +23,18 @@ const newApp = () => {
describe("completion on open/tabopen/winopen commands", () => {
const port = 12321;
let http;
- let firefox;
- let session;
+ let lanthan;
+ let webdriver;
let browser;
let body;
before(async() => {
- firefox = await lanthan.firefox({
- spy: path.join(__dirname, '..'),
- builderf: (builder) => {
- builder.addFile('build/settings.js');
- },
- });
- session = firefox.session;
- browser = firefox.browser;
+ lanthan = await Builder
+ .forBrowser('firefox')
+ .spyAddon(path.join(__dirname, '..'))
+ .build();
+ webdriver = lanthan.getWebDriver();
+ browser = lanthan.getWebExtBrowser();
http = newApp().listen(port);
await browser.storage.local.set({
@@ -44,26 +42,26 @@ describe("completion on open/tabopen/winopen commands", () => {
});
// Add item into hitories
- await session.navigateTo(`https://i-beam.org/404`);
+ await webdriver.navigate().to(`https://i-beam.org/404`);
});
after(async() => {
http.close();
- if (firefox) {
- await firefox.close();
+ if (lanthan) {
+ await lanthan.quit();
}
});
beforeEach(async() => {
- await session.navigateTo(`http://127.0.0.1:${port}`);
- body = await session.findElementByCSS('body');
+ await webdriver.navigate().to(`http://127.0.0.1:${port}`);
+ body = await webdriver.findElement(By.css('body'));
});
it('should show completions from search engines, bookmarks, and histories by "open" command', async() => {
await body.sendKeys(':');
- await session.switchToFrame(0);
- let c = new Console(session);
+ await webdriver.switchTo().frame(0);
+ let c = new Console(webdriver);
await c.sendKeys('open ');
await eventually(async() => {
@@ -77,8 +75,8 @@ describe("completion on open/tabopen/winopen commands", () => {
it('should filter items with URLs by keywords on "open" command', async() => {
await body.sendKeys(':');
- await session.switchToFrame(0);
- let c = new Console(session);
+ await webdriver.switchTo().frame(0);
+ let c = new Console(webdriver);
await c.sendKeys('open https://');
await eventually(async() => {
@@ -91,8 +89,8 @@ describe("completion on open/tabopen/winopen commands", () => {
it('should filter items with titles by keywords on "open" command', async() => {
await body.sendKeys(':');
- await session.switchToFrame(0);
- let c = new Console(session);
+ await webdriver.switchTo().frame(0);
+ let c = new Console(webdriver);
await c.sendKeys('open getting');
await eventually(async() => {
@@ -105,8 +103,8 @@ describe("completion on open/tabopen/winopen commands", () => {
it('should filter items with titles by keywords on "tabopen" command', async() => {
await body.sendKeys(':');
- await session.switchToFrame(0);
- let c = new Console(session);
+ await webdriver.switchTo().frame(0);
+ let c = new Console(webdriver);
await c.sendKeys('tabopen https://');
await eventually(async() => {
@@ -119,8 +117,8 @@ describe("completion on open/tabopen/winopen commands", () => {
it('should filter items with titles by keywords on "winopen" command', async() => {
await body.sendKeys(':');
- await session.switchToFrame(0);
- let c = new Console(session);
+ await webdriver.switchTo().frame(0);
+ let c = new Console(webdriver);
await c.sendKeys('winopen https://');
await eventually(async() => {
@@ -131,24 +129,26 @@ describe("completion on open/tabopen/winopen commands", () => {
})
it('should display only specified items in "complete" property by set command', async() => {
- let c = new Console(session);
+ let c = new Console(webdriver);
const execCommand = async(line) => {
await body.sendKeys(':');
- await session.switchToFrame(0);
- await c.sendKeys(line, Key.Enter);
- await session.switchToParentFrame();
+ await webdriver.switchTo().frame(0);
+ await c.sendKeys(line, Key.ENTER);
+ await new Promise(resolve => setTimeout(resolve, 100));
+ await webdriver.switchTo().parentFrame();
}
const typeCommand = async(...keys) => {
await body.sendKeys(':');
- await session.switchToFrame(0);
+ await webdriver.switchTo().frame(0);
await c.sendKeys(...keys);
}
const cancel = async() => {
- await c.sendKeys(Key.Escape);
- await session.switchToParentFrame();
+ await c.sendKeys(Key.ESCAPE);
+ await new Promise(resolve => setTimeout(resolve, 100));
+ await webdriver.switchTo().parentFrame();
}
await execCommand('set complete=sbh');
@@ -189,17 +189,18 @@ describe("completion on open/tabopen/winopen commands", () => {
};
await browser.storage.local.set({ settings, });
- let c = new Console(session);
+ let c = new Console(webdriver);
const typeCommand = async(...keys) => {
await body.sendKeys(':');
- await session.switchToFrame(0);
+ await webdriver.switchTo().frame(0);
await c.sendKeys(...keys);
}
const cancel = async() => {
- await c.sendKeys(Key.Escape);
- await session.switchToParentFrame();
+ await c.sendKeys(Key.ESCAPE);
+ await new Promise(resolve => setTimeout(resolve, 100));
+ await webdriver.switchTo().parentFrame();
}
await browser.storage.local.set({ settings: {