forked from zalmoxisus/crossbuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d59dd03
commit f133263
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import webdriver from 'selenium-webdriver'; | ||
import expect from 'expect'; | ||
import { check, doBefore, doAfter } from '../shared/functions'; | ||
|
||
describe('inject page (in github.com)', function() { | ||
|
||
before(function(done) { | ||
doBefore.call(this, done, () => { | ||
return this.driver.get('https://github.com'); | ||
}); | ||
}); | ||
|
||
after(doAfter); | ||
|
||
it('should open Github', function(done) { | ||
this.driver.getTitle().then((title) => { | ||
expect(title).toEqual('GitHub · Where software is built'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should render inject app', function(done) { | ||
this.timeout(8000); | ||
this.driver.wait(() => | ||
this.driver.findElements(webdriver.By.className('browser-redux')) | ||
.then(elems => elems.length > 0) | ||
, 15000, 'Inject app not found') | ||
.then(() => done()); | ||
}); | ||
|
||
it('should contain text "Clicked: 0 times"', function(done) { | ||
this.driver | ||
.findElements(webdriver.By.xpath( | ||
'//div[@class="browser-redux"][//*[contains(text(), "Clicked:")]][//*[contains(text(), "0")]][//*[contains(text(), "times")]]' | ||
)) | ||
.then((elems) => { expect(elems.length).toBe(1); }) | ||
.then(() => done()); | ||
}); | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import webdriver from 'selenium-webdriver'; | ||
|
||
export function check(done, func) { | ||
try { | ||
func(); | ||
} catch (ex) { | ||
done(ex); | ||
} | ||
} | ||
|
||
export function doBefore(done, action, load = './build/extension', port = 9515, browser = 'chrome', timeout = 6000) { | ||
this.timeout(timeout); | ||
this.driver = new webdriver.Builder() | ||
.usingServer(`http://localhost:${port}`) | ||
.withCapabilities({ | ||
chromeOptions: { | ||
args: [ `load-extension=${load}` ] | ||
} | ||
}) | ||
.forBrowser(browser) | ||
.build(); | ||
action().then(done); | ||
} | ||
|
||
export function doAfter(done, timeout = 20000) { | ||
this.timeout(timeout); | ||
this.driver.quit().then(done); | ||
} |