diff options
Diffstat (limited to 'e2e/command_tabopen.test.js')
-rw-r--r-- | e2e/command_tabopen.test.js | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/e2e/command_tabopen.test.js b/e2e/command_tabopen.test.js index 9c5cf3a..78f5d7f 100644 --- a/e2e/command_tabopen.test.js +++ b/e2e/command_tabopen.test.js @@ -1,11 +1,10 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); const settings = require('./settings'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const newApp = () => { @@ -30,22 +29,20 @@ const newApp = () => { describe("tabopen command test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; let body; before(async() => { http = newApp().listen(port); + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; await browser.storage.local.set({ settings, }); @@ -53,8 +50,8 @@ describe("tabopen command test", () => { after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); @@ -64,16 +61,16 @@ describe("tabopen command test", () => { await browser.tabs.remove(tab.id); } - 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 open default search for keywords by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen an apple', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen an apple', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -86,9 +83,9 @@ describe("tabopen command test", () => { it('should open certain search page for keywords by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen yahoo an apple', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen yahoo an apple', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -101,9 +98,9 @@ describe("tabopen command test", () => { it('should open default engine with empty keywords by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -116,9 +113,9 @@ describe("tabopen command test", () => { it('should open certain search page for empty keywords by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen yahoo', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen yahoo', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -131,9 +128,9 @@ describe("tabopen command test", () => { it('should open a site with domain by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen i-beam.org', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen i-beam.org', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -146,9 +143,9 @@ describe("tabopen command test", () => { it('should open a site with URL by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen https://i-beam.org', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen https://i-beam.org', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); |