Skip to content

Instantly share code, notes, and snippets.

@CITGuru
Created April 23, 2020 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CITGuru/b86d3d18c858599d37e60148ff63a1d8 to your computer and use it in GitHub Desktop.
Save CITGuru/b86d3d18c858599d37e60148ff63a1d8 to your computer and use it in GitHub Desktop.
const webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
const driver = new webdriver.Builder()
.forBrowser('chrome')
.build();
const URL ='http://svelte3-todo.surge.sh/'
const URL ='http://localhost:5000/'
driver.get(URL).then(function(){
driver.findElement(webdriver.By.className('js-todo-input')).sendKeys('Build App\n').then(function(){
console.log("Adding A Task: ")
driver.getPageSource().then(source=>{
// console.log(source)
if(source.includes("Build App")){
console.log("Test Passed!")
}else{
console.log("Test Failed!")
};
});
driver.findElement(webdriver.By.className("tick")).click().then(function(){
console.log("Marking Task Complete: ");
driver.findElement(webdriver.By.className("todo-item")).getAttribute("class").then(function(className){
if(className.includes("done")){
console.log("Test Passed!");
}else{
console.log("Test Failed!");
}
driver.findElement(webdriver.By.className("delete-todo")).click().then(function(){
console.log("Deleting A Task: ");
driver.getPageSource().then(source=>{
// console.log(source)
if(source.includes("Build App")){
console.log("Test Failed!");
}else{
console.log("Test Passed!");
};
});
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment