Created
February 6, 2017 06:00
-
-
Save richardfriedman/3df9be3ae82e24386a7dd171c1d5fb38 to your computer and use it in GitHub Desktop.
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
var redline = require( 'redline13-webdriver' ); | |
// For local testing | |
var browser = redline.loadBrowser('chrome'); | |
// var browser = redline.loadBrowser('phantomjs'); | |
var By = redline.webdriver.By; | |
var until = redline.webdriver.until; | |
var defaultWait = 10000; | |
var baseUrl = "http://simplecms-450361855.us-east-1.elb.amazonaws.com/cmsmadesimple/"; | |
goto( baseUrl , "Home | Performance News – Scalable Performance News" ); | |
// Search for misssing | |
browser.findElement(By.id("cntnt01searchinput")).clear(); | |
browser.findElement(By.id("cntnt01searchinput")).sendKeys("arcs"); | |
clickToTitle( By.name("submit"), "Home | Performance News – Scalable Performance News" ); | |
// Search for valid article and click through | |
browser.findElement(By.id("cntnt01searchinput")).clear(); | |
browser.findElement(By.id("cntnt01searchinput")).sendKeys("content"); | |
clickToElement( By.name("submit"), By.xpath("//a[contains(text(),'Workflow')]") ); | |
clickToTitle( By.xpath("//a[contains(text(),'Workflow')]"), "Performance News – Scalable Performance News - Workflow" ); | |
// Go Home. | |
clickToTitle( By.linkText("Home"), "Home | Performance News – Scalable Performance News" ); | |
// 10% chance of adding Posting a new post. | |
var odds = Math.floor(Math.random() * (100 - 1)) + 1; | |
if ( odds > 80 ){ | |
var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); | |
return v.toString(16); | |
}); | |
// Login to post | |
clickToTitle( By.linkText("here"), "Login to CMS Made Simple™ - Performance News – Scalable Performance News" ); | |
browser.findElement(By.id("lbusername")).clear(); | |
browser.findElement(By.id("lbusername")).sendKeys("user"); | |
browser.findElement(By.id("lbpassword")).clear(); | |
browser.findElement(By.id("lbpassword")).sendKeys("zaDNQwm4icgC"); | |
clickToTitle( By.name("loginsubmit"), "Home - Performance News – Scalable Performance News" ); | |
// Add an article | |
clickToElement( By.linkText("News"), By.linkText("Add Article") ); | |
clickToElement( By.linkText("Add Article"), By.id("m1_title") ); | |
browser.findElement(By.id("m1_title")).clear(); | |
browser.findElement(By.id("m1_title")).sendKeys("User " + guid + " posting."); | |
browser.findElement(By.name("m1_summary")).clear(); | |
browser.findElement(By.name("m1_summary")).sendKeys("Performance news by " + guid ); | |
browser.findElement(By.name("m1_content")).clear(); | |
browser.findElement(By.name("m1_content")).sendKeys("Load testing is the process of putting demand on a software system or computing device and measuring its response. Load testing is performed to determine a system's behavior under both normal and anticipated peak load conditions"); | |
clickToTitle( By.id("m1_submit"), "News - Performance News – Scalable Performance News" ); | |
// Logout and go home. | |
clickToTitle( By.linkText("Logout"), "Login to CMS Made Simple™ - Performance News – Scalable Performance News" ); | |
clickToTitle( By.css("img.goback"), "Home | Performance News – Scalable Performance News" ); | |
} | |
// browser.quit(); | |
/** | |
* Open page. | |
*/ | |
function goto( url, title ){ | |
browser.get( url ); | |
browser.wait( until.titleIs(title), defaultWait ); | |
} | |
/** | |
* Find Element, Click, Wait for Title. | |
*/ | |
function clickToTitle( button, title ){ | |
browser.sleep( 1000 ); | |
browser.wait( until.elementLocated( button ), defaultWait ); | |
browser.findElement( button ).click(); | |
browser.wait( until.titleIs(title), defaultWait ); | |
browser.sleep( Math.floor( Math.random() * defaultWait ) ); | |
} | |
/** | |
* Find Element, Click, Wait for Another Element on the Page. | |
*/ | |
function clickToElement( button, target ){ | |
browser.sleep( 1000 ); | |
browser.wait( until.elementLocated( button ), defaultWait ); | |
browser.wait( until.elementIsVisible( browser.findElement(button) ), defaultWait ); | |
browser.findElement( button ).click(); | |
browser.wait( until.elementLocated( target ), defaultWait ); | |
browser.sleep( Math.floor( Math.random() * defaultWait ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment