-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
selenium tests, only works in VB I think, but the tests work at least #47
base: master
Are you sure you want to change the base?
Changes from 1 commit
739f3b0
1635889
bd8b63d
936b7cd
26642e5
8de9d5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,12 +25,12 @@ public static class Program | |
/// <summary> | ||
/// A sequence of all test cases to run. | ||
/// </summary> | ||
private static readonly IEnumerable<TestCase> TestCases = SanityChecks.All; | ||
private static ICollection<TestCase> TestCases = UploadFileTests.All; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why'd you use Also, why exclude the sanity check tests? You can include them like so: using System.Linq;
// ...
private static readonly IEnumerable<TestCase> TestCases =
SanityChecks.All
.Concat(UploadFileTests.All); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might also want to include all the other tests here. |
||
|
||
public static int Main(string[] args) | ||
{ | ||
// Acquire a log for printing output. | ||
var rawLog = new RecordingLog(TerminalLog.Acquire()); | ||
var rawLog = new RecordingLog(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why'd you change this? This'll secretly eat up all error messages, making it impossible to tell what happened when something went wrong. The tests will still fail by exiting with a nonzero exit code, but that will be obscured now. |
||
|
||
// Create a derived log for printing diagnostics. | ||
var log = CreateDiagnosticLog(rawLog); | ||
|
@@ -78,7 +78,8 @@ public static int Main(string[] args) | |
return 0; | ||
} | ||
|
||
string testUrl = parsedOptions.GetValue<string>(Options.Url); | ||
//string testUrl = parsedOptions.GetValue<string>(Options.Url); | ||
string testUrl = "http://192.168.1.12:5000"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change this back. You can specify |
||
bool noUrl = string.IsNullOrWhiteSpace(testUrl); | ||
|
||
if ((noUrl && !parsedOptions.ContainsOption(Options.BuildApplication)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System.Collections.Generic; | ||
using OpenQA.Selenium; | ||
using System; | ||
using System.Windows.Forms; | ||
|
||
namespace SeleniumTests.Tests | ||
{ | ||
class EditGraphTests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These test classes contain |
||
{ | ||
public static readonly TestCase DeleteSHACLShape = | ||
new TestCase( | ||
"SHACL shapes can be deleted", | ||
(driver, log) => | ||
{ | ||
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); | ||
//Log in | ||
driver.Login(); | ||
String currentPath = System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName; | ||
String path = currentPath + @"\testfiles\demo_shacl.ttl"; | ||
//Open a SHACL file | ||
driver.OpenFile(path); | ||
IWebElement shaclElement = driver.FindElement(By.XPath("//*[contains(text(),'PersonShape')]"), 10); | ||
shaclElement.Click(); | ||
SendKeys.SendWait("{DEL}"); | ||
System.Threading.Thread.Sleep(500); | ||
try | ||
{ | ||
IReadOnlyCollection<IWebElement> elements = driver.FindElements(By.Id(shaclElement.GetAttribute("Id"))); | ||
Assert.IsTrue(elements.Count == 0); | ||
} | ||
catch (StaleElementReferenceException) { | ||
Assert.IsTrue(true); | ||
} | ||
}); | ||
|
||
public static readonly TestCase DeleteDataShape = | ||
new TestCase( | ||
"Data shapes can be deleted", | ||
(driver, log) => | ||
{ | ||
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); | ||
//Log in | ||
driver.Login(); | ||
String currentPath = System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName; | ||
String path = currentPath + @"\testfiles\demo_data_conforming.ttl"; | ||
//Open a SHACL file | ||
driver.OpenFile(path); | ||
var dataElement = driver.FindElement(By.XPath("//*[contains(text(),'ex:Alice')]"), 10); | ||
dataElement.Click(); | ||
SendKeys.SendWait("{DEL}"); | ||
System.Threading.Thread.Sleep(500); | ||
try | ||
{ | ||
bool b = dataElement.Displayed; | ||
Assert.IsTrue(false); | ||
} | ||
catch (OpenQA.Selenium.StaleElementReferenceException) { } | ||
}); | ||
|
||
public static readonly ICollection<TestCase> All = | ||
new[] | ||
{ | ||
DeleteSHACLShape | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections.Generic; | ||
using OpenQA.Selenium; | ||
using System; | ||
|
||
namespace SeleniumTests.Tests | ||
{ | ||
class GraphTests | ||
{ | ||
|
||
public static readonly TestCase DeleteSHACLProperty = | ||
new TestCase( | ||
"SHACL properties can be deleted", | ||
(driver, log) => | ||
{ | ||
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); | ||
//Log in | ||
driver.Login(); | ||
String currentPath = System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName; | ||
String path = currentPath + @"\testfiles\demo_shacl.ttl"; | ||
//Open a SHACL file | ||
driver.OpenFile(path); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the following getting duplicated over and over again. String currentPath = System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName;
String path = currentPath + @"\testfiles\demo_shacl.ttl";
// Open a SHACL file
driver.OpenFile(path); You might want to refactor that pattern into a specialized (extension?) method, so you can just call |
||
var shaclElement = driver.FindElement(By.XPath("//*[contains(text(),'sh:targetClass')]"), 10); | ||
Assert.IsTrue(shaclElement.Text == "sh:targetClass : ex:Person"); | ||
}); | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System.Collections.Generic; | ||
using OpenQA.Selenium; | ||
using System.Windows.Forms; | ||
using OpenQA.Selenium.Interactions; | ||
using System; | ||
using OpenQA.Selenium.Support.UI; | ||
|
||
namespace SeleniumTests.Tests | ||
{ | ||
static class Help | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rename this class to |
||
{ | ||
|
||
public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds) | ||
{ | ||
if (timeoutInSeconds > 0) | ||
{ | ||
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds)); | ||
return wait.Until(drv => drv.FindElement(by)); | ||
} | ||
return driver.FindElement(by); | ||
} | ||
|
||
public static IReadOnlyCollection<IWebElement> FindElements(this IWebDriver driver, By by, int timeoutInSeconds) | ||
{ | ||
if (timeoutInSeconds > 0) | ||
{ | ||
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds)); | ||
return wait.Until(drv => drv.FindElements(by)); | ||
} | ||
return driver.FindElements(by); | ||
} | ||
|
||
public static void DoubleClick(this IWebDriver driver, IWebElement element) | ||
{ | ||
Actions action = new Actions(driver); | ||
action.DoubleClick(element); | ||
action.Perform(); | ||
} | ||
|
||
public static void Login(this IWebDriver driver) | ||
{ | ||
var elem = driver.FindElement(By.Id("homeLoginButton")); | ||
elem.Click(); | ||
Assert.IsTrue(driver.Url.EndsWith("#/login")); | ||
driver.FindElement(By.Id("formUsernameField")).SendKeys("username"); | ||
driver.FindElement(By.Id("formPasswordField")).SendKeys("password"); | ||
var login = driver.FindElement(By.Id("formLoginButton")); | ||
login.Click(); | ||
} | ||
|
||
public static void OpenFile(this IWebDriver driver, String path) | ||
{ | ||
var fileMenu = driver.FindElement(By.Id("openFileMenu"), 10); | ||
fileMenu.Click(); | ||
var localGraph = driver.FindElement(By.Id("openLocalGraphButton"), 10); | ||
localGraph.Click(); | ||
var shaclGraph = driver.FindElement(By.Id("openSHACLGraphButton"), 10); | ||
shaclGraph.Click(); | ||
SendKeys.SendWait(path); | ||
System.Threading.Thread.Sleep(500); | ||
SendKeys.SendWait(@"{Enter}"); | ||
System.Threading.Thread.Sleep(1000); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,14 +29,27 @@ public static class SanityChecks | |
Assert.IsTrue(driver.Url.EndsWith("#/about")); | ||
}); | ||
|
||
public static readonly TestCase LoginWorks = | ||
new TestCase( | ||
"Login page can be accessed", | ||
(driver, log) => | ||
{ | ||
//Log in | ||
driver.Login(); | ||
// Check that we're at '#/user' after logging in. | ||
Assert.IsTrue(driver.Url.EndsWith("#/user")); | ||
|
||
}); | ||
|
||
/// <summary> | ||
/// A list of all sanity check tests. | ||
/// </summary> | ||
public static readonly IEnumerable<TestCase> All = | ||
public static readonly ICollection<TestCase> All = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why'd you change this to |
||
new[] | ||
{ | ||
CheckTitle, | ||
AboutWorks | ||
AboutWorks, | ||
LoginWorks | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Collections.Generic; | ||
using OpenQA.Selenium; | ||
using System; | ||
|
||
namespace SeleniumTests.Tests | ||
{ | ||
class UploadFileTests | ||
{ | ||
public static readonly TestCase UploadSHACLFile = | ||
new TestCase( | ||
"SHACL files can be uploaded", | ||
(driver, log) => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation seems kind of off here. Can you reformat this lambda? |
||
{ | ||
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); | ||
//Log in | ||
driver.Login(); | ||
String currentPath = System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not insert a |
||
String path = currentPath + @"\testfiles\demo_shacl.ttl"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should use |
||
//Open a SHACL file | ||
driver.OpenFile(path); | ||
var shaclElement = driver.FindElement(By.XPath("//*[contains(text(),'sh:targetClass')]"), 10); | ||
Assert.IsTrue(shaclElement.Text == "sh:targetClass : ex:Person"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using |
||
}); | ||
|
||
public static readonly TestCase UploadDataFile = | ||
new TestCase( | ||
"Data files can be uploaded", | ||
(driver, log) => | ||
{ | ||
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); | ||
//Log in | ||
driver.Login(); | ||
String currentPath = System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName; | ||
String path = currentPath + @"\testfiles\demo_data_conforming.ttl"; | ||
//Open a SHACL file | ||
driver.OpenFile(path); | ||
var dataElement = driver.FindElement(By.XPath("//*[contains(text(),'ex:Alice')]"), 10); | ||
Assert.IsTrue(dataElement.Text == "ex:Alice"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
}); | ||
|
||
public static readonly ICollection<TestCase> All = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why'd you use |
||
new[] | ||
{ | ||
UploadSHACLFile, | ||
UploadDataFile | ||
}; | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. | ||
@prefix sh: <http://www.w3.org/ns/shacl#>. | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. | ||
@prefix ex: <http://example.com/ns#>. | ||
|
||
ex:Alice a ex:Person ; | ||
ex:ssn "987-65-432" . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. | ||
@prefix sh: <http://www.w3.org/ns/shacl#>. | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. | ||
@prefix ex: <http://example.com/ns#>. | ||
ex:Bob | ||
a ex:Person ; | ||
ex:ssn "123-45-6789" ; | ||
ex:ssn "124-35-6789" . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. | ||
@prefix sh: <http://www.w3.org/ns/shacl#>. | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. | ||
@prefix ex: <http://example.com/ns#>. | ||
|
||
ex:PersonShape | ||
a sh:NodeShape ; | ||
sh:targetClass ex:Person ; | ||
sh:property [ | ||
sh:path ex:ssn ; | ||
sh:maxCount 1 ; | ||
sh:datatype xsd:string ; | ||
sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ; | ||
] ; | ||
sh:property [ | ||
sh:path ex:worksFor ; | ||
sh:class ex:Company ; | ||
sh:nodeKind sh:IRI ; | ||
] ; | ||
sh:closed true ; | ||
sh:ignoredProperties ( rdf:type ) . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually useful or is this just dead code?
Installing NuGet as a separate global dependency shouldn't be a problem at all for people who already installed a C# compiler and an MSBuild-like build system. But maybe you've got a different perspective on that and this line is warranted anyway.
Regardless, please don't put NuGet in the
package.json
's"dependencies"
—if you really do need it, put it in the"devDependencies"
.