-
Notifications
You must be signed in to change notification settings - Fork 15
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
Showing
34 changed files
with
568 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as childProcess from 'child_process'; | ||
import { MockWebServer } from './src/mock-web-server'; | ||
|
||
const mockWebServer = new MockWebServer(); | ||
mockWebServer.start(); | ||
|
||
const testringProcess = childProcess.exec( | ||
'./node_modules/.bin/testring run --config ./test/selenium/config.js', | ||
{}, | ||
(error, stdout, stderr) => { | ||
mockWebServer.stop(); | ||
|
||
if (error) { | ||
throw error; | ||
} | ||
}); | ||
|
||
if (testringProcess.stdout) { | ||
testringProcess.stdout.pipe(process.stdout); | ||
} else { | ||
console.warn('Cannot pipe stdout of child process'); | ||
} | ||
|
||
if (testringProcess.stderr) { | ||
testringProcess.stderr.pipe(process.stderr); | ||
} else { | ||
console.warn('Cannot pipe stderr of child process'); | ||
} |
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
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,20 @@ | ||
import * as express from 'express'; | ||
import * as Http from 'http'; | ||
|
||
export class MockWebServer { | ||
private httpServerInstance: Http.Server; | ||
|
||
start() { | ||
this.httpServerInstance = MockWebServer.createExpressWebApplication().listen(8080); | ||
} | ||
|
||
stop() { | ||
this.httpServerInstance.close(); | ||
} | ||
|
||
private static createExpressWebApplication(): express.Application { | ||
const app = express(); | ||
app.use(express.static('static-fixtures')); | ||
return app; | ||
} | ||
} |
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,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body data-test-automation-id="root"> | ||
<div data-test-automation-id="alerts"> | ||
<p data-test-automation-id="first" class="alerts"></p> | ||
<p data-test-automation-id="second" class="alerts"></p> | ||
<p data-test-automation-id="third" class="alerts"></p> | ||
</div> | ||
<script> | ||
const a1 = confirm(); | ||
document.getElementsByClassName('alerts')[0].innerText = a1; | ||
|
||
const a2 = confirm(); | ||
document.getElementsByClassName('alerts')[1].innerText = a2; | ||
|
||
const a3 = confirm('test'); | ||
document.getElementsByClassName('alerts')[2].innerText = a3; | ||
</script> | ||
</body> | ||
</html> |
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,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
<script> | ||
function test() { | ||
document.getElementById('output').innerText = 'test'; | ||
} | ||
</script> | ||
</head> | ||
<body data-test-automation-id="root"> | ||
<button data-test-automation-id="button" onclick="test()">Press me!</button> | ||
<p id="output" data-test-automation-id="output"></p> | ||
</body> | ||
</html> |
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,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
<script> | ||
function printCookie() { | ||
document.getElementById('cookie_found').innerText = document.cookie; | ||
} | ||
|
||
document.cookie = 'test=TestData'; | ||
</script> | ||
</head> | ||
<body data-test-automation-id="root"> | ||
<button data-test-automation-id="cookie_clear_button" onclick="printCookie()">Cookie cleared!</button> | ||
<p id="cookie_found" data-test-automation-id="cookie_found_text"></p> | ||
</body> | ||
</html> |
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,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
<style> | ||
.customDivClass { | ||
background-color: darkred; | ||
} | ||
|
||
.becomeVisible { | ||
visibility: hidden; | ||
} | ||
</style> | ||
<script> | ||
function showHidden() { | ||
document.getElementById('becomeVisible').style.visibility = 'visible'; | ||
} | ||
|
||
function hideVisible() { | ||
document.getElementById('becomeHidden').style.visibility = 'hidden'; | ||
} | ||
</script> | ||
</head> | ||
<body data-test-automation-id="root"> | ||
<div class="customDivClass" data-test-automation-id="withClass"></div> | ||
<div style="background-color: red;" data-test-automation-id="withStyle"></div> | ||
|
||
<div data-test-automation-id="becomeVisible" class="becomeVisible" id="becomeVisible">becomeVisible</div> | ||
<div data-test-automation-id="becomeHidden" id="becomeHidden">becomeHidden</div> | ||
|
||
<button data-test-automation-id="showHiddenButton" onclick="showHidden()">show hidden</button> | ||
<button data-test-automation-id="hideVisibleButton" onclick="hideVisible()">hide visible</button> | ||
</body> | ||
</html> |
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,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body data-test-automation-id="root"> | ||
<ul data-test-automation-id="existingElement"> | ||
<li data-test-automation-id="li"></li> | ||
<li data-test-automation-id="li"></li> | ||
<li data-test-automation-id="li"></li> | ||
<li data-test-automation-id="li"></li> | ||
<li data-test-automation-id="li"></li> | ||
</ul> | ||
</body> | ||
</html> |
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 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
</head> | ||
<body data-test-automation-id="root"> | ||
<form data-test-automation-id="form"> | ||
<div> | ||
<label for="nameInput">Name: </label><input id="nameInput" type="text" placeholder="name" data-test-automation-id="nameInput"> | ||
</div> | ||
<div> | ||
<label for="disabledInput">disabled: </label> | ||
<input id="disabledInput" type="text" placeholder="disabled" data-test-automation-id="disabledInput" disabled> | ||
</div> | ||
<div> | ||
<label for="readonlyInput">readonly: </label> | ||
<input id="readonlyInput" type="text" placeholder="readonly" data-test-automation-id="readonlyInput" readonly value="readonly"> | ||
</div> | ||
<div> | ||
<input id="checkbox" type="checkbox" data-test-automation-id="checkbox"> | ||
<label for="checkbox">checkbox label</label> | ||
</div> | ||
<div> | ||
<input id="checkbox2" type="checkbox" data-test-automation-id="checkbox_2" checked="checked"> | ||
<label for="checkbox2">checkbox label with initial checked</label> | ||
</div> | ||
<div> | ||
<label for="select">Choose: </label> | ||
<select id="select" data-test-automation-id="select"> | ||
<option data-test-attr="value" value="byAttribute">By attribute</option> | ||
<option name="testName" value="byName">By name</option> | ||
<option value="byIndex">By index</option> | ||
<option value="byValue">By value</option> | ||
<option value="byVisibleText" id="select-option-visible-text">By visible text</option> | ||
<option data-test-automation-id="option" value="withTestId" id="select-test-option">With test id</option> | ||
</select> | ||
</div> | ||
</form> | ||
</body> | ||
</html> |
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,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
<script> | ||
var addedForIds = []; | ||
|
||
function appendText4(id) { | ||
if (addedForIds.indexOf(id) !== -1) { | ||
return; | ||
} | ||
|
||
document.getElementById(id).append('Text 4'); | ||
addedForIds.push(id); | ||
} | ||
</script> | ||
</head> | ||
<body data-test-automation-id="root"> | ||
<div data-test-automation-id="container"><p>test</p></div> | ||
<div data-test-automation-id="text">Text is here!</div> | ||
<div data-test-automation-id="texts" id="texts" onmouseover="appendText4('texts')"> | ||
<p>Text 1</p> | ||
<p>Text 2</p> | ||
<p>Text 3</p> | ||
</div> | ||
<div data-test-automation-id="textWithoutFocus" id="textWithoutFocus" onmouseover="appendText4('textWithoutFocus')">Text without focus</div> | ||
</body> | ||
</html> |
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,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Scroll test</title> | ||
<style> | ||
.container { | ||
height: 200px; | ||
width: 200px; | ||
overflow: auto; | ||
background: aliceblue; | ||
} | ||
</style> | ||
</head> | ||
<body data-test-automation-id="root"> | ||
<div class="container" data-test-automation-id="container" id="container"> | ||
<p data-test-automation-id="item_1" id="item_1">Text 1</p> | ||
<p>Text 2</p> | ||
<p>Text 3</p> | ||
<p>Text 4</p> | ||
<p>Text 5</p> | ||
<p>Text 6</p> | ||
<p data-test-automation-id="item_7">Text 7</p> | ||
<p data-test-automation-id="item_8">Text 8</p> | ||
<p>Text 9</p> | ||
<p data-test-automation-id="item_10" id="item_10">Text 10</p> | ||
</div> | ||
</body> | ||
</html> |
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,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>original title</title> | ||
<script> | ||
function changeTitle() { | ||
document.title = 'title changed'; | ||
} | ||
</script> | ||
</head> | ||
<body data-test-automation-id="root"> | ||
<button data-test-automation-id="changeTitleButton" onclick="changeTitle()">Change title</button> | ||
</body> | ||
</html> |
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,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
<script> | ||
function showElement() { | ||
setTimeout(() => { | ||
const elem = document.createElement('div'); | ||
elem.setAttribute('data-test-automation-id', 'shouldExist'); | ||
|
||
document.body.prepend(elem); | ||
}, 1000); | ||
} | ||
</script> | ||
</head> | ||
<body data-test-automation-id="root"> | ||
<button data-test-automation-id="showElement" onclick="showElement()">show</button> | ||
</body> | ||
</html> |
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,18 @@ | ||
import { run } from 'testring'; | ||
|
||
run(async (api) => { | ||
await api.application.url('http://localhost:8080/alert.html'); | ||
|
||
await api.application.alertAccept(); | ||
await api.application.alertDismiss(); | ||
const text = await api.application.alertText(); | ||
|
||
const firstAlertState = await api.application.getText(api.application.root.alerts.first); | ||
const secondAlertState = await api.application.getText(api.application.root.alerts.second); | ||
const thirdAlertState = await api.application.getText(api.application.root.alerts.third); | ||
|
||
api.application.assert.equal(firstAlertState, 'true'); | ||
api.application.assert.equal(secondAlertState, 'false'); | ||
api.application.assert.equal(thirdAlertState, 'false'); | ||
api.application.assert.equal(text, 'test'); | ||
}); |
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,12 @@ | ||
import { run } from 'testring'; | ||
|
||
run(async (api) => { | ||
await api.application.url('http://localhost:8080/click.html'); | ||
|
||
await api.application.click( | ||
api.application.root.button | ||
); | ||
|
||
const outputText = await api.application.getText(api.application.root.output); | ||
api.application.assert.equal(outputText, 'test'); | ||
}); |
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,13 @@ | ||
import { run } from 'testring'; | ||
|
||
run(async (api) => { | ||
await api.application.url('http://localhost:8080/cookie.html'); | ||
const cookieValue = await api.application.getCookie('test'); | ||
await api.application.assert.equal(cookieValue, 'TestData'); | ||
|
||
await api.application.deleteCookie('test'); | ||
await api.application.click(api.application.root.cookie_clear_button); | ||
|
||
const cookieTextAfterDelete = await api.application.getText(api.application.root.cookie_found_text); | ||
await api.application.assert.equal(cookieTextAfterDelete, ''); | ||
}); |
Oops, something went wrong.