2016-09-14 15:28:45 -04:00
|
|
|
/*
|
|
|
|
* Checks that the links in the navbar on the homepage have the right URLs to redirect to
|
|
|
|
*
|
|
|
|
* Test cases: https://github.com/LLK/scratch-www/wiki/Most-Important-Workflows#Create_should_take_you_to_the_editor
|
|
|
|
*/
|
|
|
|
|
2016-09-15 13:22:53 -04:00
|
|
|
var tap=require('tap');
|
|
|
|
var seleniumWebdriver = require('selenium-webdriver');
|
2016-09-14 15:28:45 -04:00
|
|
|
|
2016-09-14 15:33:45 -04:00
|
|
|
/*
|
|
|
|
* Remove question comments after resolving them
|
|
|
|
*/
|
2016-09-15 13:22:53 -04:00
|
|
|
//how to generalize for other browsers... how will this work in saucelabs? Do I need to iterate
|
2016-09-15 10:36:47 -04:00
|
|
|
//through the drivers for each browser here?
|
2016-09-14 15:28:45 -04:00
|
|
|
//chrome driver
|
|
|
|
var driver = new seleniumWebdriver.Builder().withCapabilities(seleniumWebdriver.Capabilities.chrome()).build();
|
|
|
|
//open scratch.ly in a new instance of the browser
|
2016-09-15 10:36:47 -04:00
|
|
|
driver.get('https://scratch.ly');
|
2016-09-14 15:28:45 -04:00
|
|
|
|
|
|
|
/*
|
2016-09-14 15:33:45 -04:00
|
|
|
* Remove question comments after resolving them
|
2016-09-14 15:28:45 -04:00
|
|
|
*/
|
|
|
|
//find the navbar
|
|
|
|
//var navbarElement = driver.findElement(seleniumWebdriver.By.id("navigation"))
|
2016-09-15 10:36:47 -04:00
|
|
|
//var createLinkSignedOut = navbarElement.findElement(seleniumWebdriver.By.xpath('//li[@class="link create"]/a'))
|
|
|
|
//^^this doesn't work to force findElement to look in the scope of navbarElement
|
2016-09-14 15:28:45 -04:00
|
|
|
|
|
|
|
//find the create link within the navbar
|
|
|
|
//the create link depends on whether the user is signed in or not (tips window opens)
|
|
|
|
|
2016-09-14 15:33:45 -04:00
|
|
|
/*
|
|
|
|
* Remove question comments after resolving them
|
|
|
|
*/
|
2016-09-14 15:28:45 -04:00
|
|
|
//this xpath is fragile, can i look up by successive attributes instead?
|
|
|
|
tap.test('checkCreateLinkWhenSignedOut', function (t) {
|
2016-09-15 13:28:17 -04:00
|
|
|
var xPathLink = '//div[@id="navigation"]/div[@class="inner"]/ul/li[@class="link create"]/a';
|
2016-09-15 13:22:53 -04:00
|
|
|
var createLinkSignedOut = driver.findElement(seleniumWebdriver.By.xpath(xPathLink));
|
2016-09-15 10:36:47 -04:00
|
|
|
createLinkSignedOut.getAttribute('href').then( function (href) {
|
|
|
|
t.equal('https://scratch.ly/projects/editor/?tip_bar=home', href);
|
|
|
|
t.end();
|
|
|
|
});
|
2016-09-14 15:28:45 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// close the instance of the browser
|
|
|
|
driver.quit();
|
|
|
|
|