Created
July 8, 2018 16:24
-
-
Save Kameshwaran/49cc1541db8aec1c07ec29f6712b7b75 to your computer and use it in GitHub Desktop.
selenium test
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
const { Builder, By, until } = require('selenium-webdriver'); | |
const driver = new Builder() | |
.forBrowser('chrome') | |
.build(); | |
const waitForTitle = () => { | |
return driver.getTitle().then((title) => title.includes('JSFiddle')); | |
} | |
const runTests = () => { | |
return new Promise(async (onDone, onError) => { | |
const totalNumberOfTests = 2; | |
let testsPassed = 0; | |
try { | |
driver.switchTo().frame(driver.findElement(By.tagName('iframe'))); | |
var square = driver.findElement(By.id('square')); | |
var button = driver.findElement(By.id('button')); | |
const borderRadius = await square.getCssValue('border-radius'); | |
const backgroundColor = await square.getCssValue('background-color'); | |
button.click(); | |
const newBorderRadius = await square.getCssValue('border-radius'); | |
const newBackgroundColor = await square.getCssValue('background-color'); | |
if (borderRadius !== newBorderRadius && parseInt(newBorderRadius) > 45) { return testsPassed++; } | |
if (backgroundColor !== newBackgroundColor) { return testsPassed++; } | |
onDone(testsPassed, totalNumberOfTests); | |
return driver.wait(waitForTitle, 1500); | |
} | |
catch(e) { | |
onError(e); | |
} | |
}) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment