Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to add some phantom tests

  • Loading branch information...
commit a70bcf5609f0f527d5adab5097f80244e1b1e094 1 parent 0bb44e6
@scryan7371 authored
Showing with 38 additions and 48 deletions.
  1. +2 −2 src/main/index.html
  2. +36 −46 src/test/integration/phantom/mainTest.js
View
4 src/main/index.html
@@ -40,7 +40,7 @@
<div data-role="navbar">
<ul>
<li><a id="process-generate" class="ui-btn-active" href="#">Generate</a></li>
- <li><a href="#reset-generator" data-rel="dialog" data-transition="flip">Reset</a></li>
+ <li><a id="show-reset" href="#reset-generator" data-rel="dialog" data-transition="flip">Reset</a></li>
</ul>
</div>
<div id="gen-panel">
@@ -71,7 +71,7 @@
<input id="max-count-input" type="text" maxlength="5">
</div>
<a id="process-reset" href="#" data-role="button" data-inline="true">Save</a>
- <a href="#generator" data-role="button" data-inline="true" data-rel="back">Cancel</a>
+ <a id="cancel-reset" href="#generator" data-role="button" data-inline="true" data-rel="back">Cancel</a>
</form>
</div>
</div>
View
82 src/test/integration/phantom/mainTest.js
@@ -32,56 +32,46 @@ function waitFor(testFx, onReady, timeOutMillis) {
}
}, 250); //< repeat check every 250ms
}
+
var page = new WebPage();
+
+/**
+ * This allows logging from inside the page during an evaluate.
+ * @param inMessage - The message to process.
+ */
+page.onConsoleMessage = function(inMessage) {
+ console.log(inMessage);
+};
+
page.open("../../../main/index.html", function (status) {
- var menuPresent = false;
if (status !== 'success') {
console.log('Unable to load the address!');
}
else {
- /*
- // Bring up main menu and take a screen capture
- waitFor(function() {
- // Check in the page if a specific element is now visible
- return page.evaluate(function() {
- return document.getElementById('watch-menu-item').innerText.indexOf("Watch") > 0;
- });
- }, function() {
- console.log("The main menu is visible now");
- page.render("menu.png");
- menuPresent = true;
- });
- // now bring up the box art
- waitFor(function() {
- return menuPresent;
- }, function() {
- console.log("Sending Keystrokes");
- page.evaluate(sendKeyPress(13));
- sendKeyPress(13);
- });
- // now bring up the box art
- waitFor(function() {
- // Check in the page if a specific element is now visible
- return page.evaluate(function() {
- return document.getElementById('sortType').innerText.indexOf("items by ") > 0;
- });
- }, function() {
- console.log("The watch grid is visible now");
- page.render("watchGrid.png");
- phantom.exit();
- });
- */
- console.log("The main panel is visible");
- page.render("image/mainPanel.png");
- phantom.exit();
+ // Bring up main menu and take a screen capture
+ waitFor(function() {
+ // Check if the page is now visible
+ return page.evaluate(function() {
+ return $("#generator").is(":visible");
+ });
+ }, function() {
+ console.log("The main menu is visible now");
+ page.render("image/menu.png");
+ // Click the show reset button
+ page.evaluate(function() {
+ $("#show-reset").click();
+ });
+ waitFor(function() {
+ // Check if the page is now visible
+ return page.evaluate(function() {
+ return $("#reset-generator").is(":visible");
+ });
+ }, function() {
+ console.log("The reset is visible now");
+ page.render("image/reset.png");
+ // Exit Phantom
+ phantom.exit();
+ });
+ });
}
-});
-
-function sendKeyPress(inKeyCode) {
- console.log(document.getElementById('watch-menu-item'));
- var element = document.getElementById("keyhandlerId");
- console.log("element is " + element);
- var event = document.createEvent("KeyboardEvent");
- event.initKeyboardEvent("keypress", true, true, window, 0, 0, 0, 0, 0, inKeyCode);
- element.dispatchEvent(event);
-}
+});

0 comments on commit a70bcf5

Please sign in to comment.
Something went wrong with that request. Please try again.