-
Notifications
You must be signed in to change notification settings - Fork 200
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
Add selenium tests for alert pages #34 #116
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0c86412
Add selenium tests for alert pages
c321246
Additional comments
4e7e5b7
Merge pull request #1 from siglens/develop
shyam2520 6d29f1b
PR fixes
2ff1266
Merge pull request #2 from shyam2520/alerts-selenium
shyam2520 8180c9a
Merge branch 'siglens:develop' into develop
shyam2520 22a3155
Merge branch 'develop' into develop
shyam2520 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add selenium tests for alert pages
- Added Test for check any elements visibility , editability and response - Induced bugs in alerts htmls to check if the test gets picked or not
- Loading branch information
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
// const {Builder, By, Key, until} = require('selenium-webdriver'); | ||
|
||
// (async function example() { | ||
// let driver = await new Builder().forBrowser('chrome').build(); | ||
// try { | ||
// await driver.get('http://www.google.com/ncr'); | ||
// // await driver.findElement(By.name('q'));.sendKeys('webdriver', Key.RETURN); | ||
// // await driver.wait(until.titleIs('webdriver - Google Search'), 1000); | ||
// } finally { | ||
// // await driver.quit(); | ||
// console.log("done") | ||
// } | ||
// })(); | ||
|
||
const { By, Key, Builder, WebElement } = require("selenium-webdriver"); | ||
const assert = require("assert"); | ||
const chrome = require('selenium-webdriver/chrome'); | ||
let driver; | ||
const chromeOptions = new chrome.Options() | ||
|
||
// chromeOptions.addArguments('--headless'); | ||
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 uncomment this line. 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 have made the changes for the same |
||
async function checkIncrementor(Component){ | ||
const initialValue = await Component.getAttribute('value'); | ||
// Attempt to increment the value | ||
await Component.sendKeys(Key.ARROW_UP); | ||
// Get the value after incrementing | ||
const incrementedValue = await Component.getAttribute('value'); | ||
// Assert that the value has been incremented | ||
assert.notStrictEqual(incrementedValue, initialValue, 'Failed to increment the number input.'); | ||
// Attempt to decrement the value | ||
await Component.sendKeys(Key.ARROW_DOWN); | ||
// Get the value after decrementing | ||
const decrementedValue = await Component.getAttribute('value'); | ||
assert.notStrictEqual(decrementedValue, incrementedValue, 'Failed to decrement the number input.'); | ||
|
||
} | ||
async function testAlertPagesButtons() { | ||
try{ | ||
driver = await new Builder().forBrowser("chrome") | ||
.setChromeOptions(chromeOptions) | ||
.build(); | ||
|
||
//To fetch http://localhost/index.html from the browser with our code. | ||
|
||
await driver.get("http://localhost/alert.html"); | ||
let cancelBtn = driver.findElement(By.id("cancel-alert-btn")); | ||
let cancelTxt = await cancelBtn.getText(); | ||
let saveBtn = driver.findElement(By.id("save-alert-btn")); | ||
let saveTxt = await saveBtn.getText(); | ||
|
||
assert.equal(cancelTxt, "Cancel", 'button text is not "Cancel"'); | ||
assert.equal(saveTxt, "Save", 'button text is not "Save"'); | ||
|
||
|
||
let alertRuleInputTextBox = await driver.findElement(By.id("alert-rule-name")); | ||
// alertRuleInputTextBox.sendKeys("test"); | ||
const checkAlertRuleEditable = await alertRuleInputTextBox.isEnabled(); | ||
assert.strictEqual(checkAlertRuleEditable, true, 'alert rule input text box is not editable'); | ||
|
||
let logsBtn = await driver.findElement(By.id("alert-data-source")); | ||
// assert.equal(await logsBtn.getText(), "Logs", 'button text is not "Logs"'); | ||
await logsBtn.click(); | ||
let logsDrpDownPresent= await driver.findElement(By.id("data-source-options")).isDisplayed(); | ||
assert.strictEqual(logsDrpDownPresent, true, 'logs dropdown is not displayed'); | ||
await logsBtn.click(); | ||
|
||
let logsLanguageBtn = await driver.findElement(By.id('logs-language-btn')); | ||
await logsLanguageBtn.click(); | ||
let logsLanguageDrpDownPresent= await driver.findElement(By.id("logs-language-options")).isDisplayed(); | ||
assert.strictEqual(logsLanguageDrpDownPresent, true, 'logs language dropdown is not displayed'); | ||
await logsLanguageBtn.click(); | ||
|
||
let datePickerBtn = await driver.findElement(By.id('date-picker-btn')); | ||
await datePickerBtn.click(); | ||
let datePickerDrpDownPresent= await driver.findElement(By.id("daterangepicker ")).isDisplayed(); | ||
assert.strictEqual(datePickerDrpDownPresent, true, 'date picker dropdown is not displayed'); | ||
await datePickerBtn.click(); | ||
|
||
let queryTextBox = await driver.findElement(By.id('query')); | ||
const checkQueryEditable = await queryTextBox.isEnabled(); | ||
assert.strictEqual(checkQueryEditable, true, 'query text box is not editable'); | ||
|
||
let alertThresholdTextBox = await driver.findElement(By.id('alert-condition')); | ||
await alertThresholdTextBox.click(); | ||
let alertThresholdDrpDownPresent= await driver.findElement(By.className("dropdown-menu box-shadow alert-condition-options show")).isDisplayed(); | ||
assert.strictEqual(alertThresholdDrpDownPresent, true, 'alert threshold dropdown is not displayed'); | ||
await alertThresholdTextBox.click(); | ||
|
||
let alertThresholdInputTextBox = await driver.findElement(By.id('threshold-value')); | ||
const checkAlertThresholdEditable = await alertThresholdInputTextBox.isEnabled(); | ||
assert.strictEqual(checkAlertThresholdEditable, true, 'alert threshold input text box is not editable'); | ||
await checkIncrementor(alertThresholdInputTextBox); | ||
|
||
let evaluateEveryTextBox = await driver.findElement(By.id('evaluate-every')); | ||
const checkEvaluateEveryEditable = await evaluateEveryTextBox.isEnabled(); | ||
assert.strictEqual(checkEvaluateEveryEditable, true, 'evaluate every input text box is not editable'); | ||
await checkIncrementor(evaluateEveryTextBox); | ||
|
||
let evaluteForTextBox = await driver.findElement(By.id('evaluate-for')); | ||
|
||
const checkAlertForEditable = await evaluteForTextBox.isEnabled(); | ||
assert.strictEqual(checkAlertForEditable, true, 'alert for input text box is not editable'); | ||
await checkIncrementor(evaluteForTextBox); | ||
|
||
|
||
let contactsPtsBtn = await driver.findElement(By.id('contact-points-dropdown')); | ||
await contactsPtsBtn.click(); | ||
let contactPtsDrpDownPresent= await driver.findElement(By.className("dropdown-menu box-shadow contact-points-options show")).isDisplayed(); | ||
assert.strictEqual(contactPtsDrpDownPresent, true, 'contact points dropdown is not displayed'); | ||
contactPtsDrpDown=await driver.findElement(By.className("dropdown-menu box-shadow contact-points-options show")) | ||
let addNewBtnForContact = await contactPtsDrpDown.findElement(By.id('option-0')); | ||
// console.log(addNewBtnForContact.getText()); | ||
assert.strictEqual(await addNewBtnForContact.getText(), 'Add New', 'Add new button is not present'); | ||
await addNewBtnForContact.click(); | ||
|
||
let cancelBtnForContact = await driver.findElement(By.id('cancel-contact-btn')); | ||
let cancelBtnTxt = await cancelBtnForContact.getText(); | ||
assert.strictEqual(cancelBtnTxt, 'Cancel', 'Cancel button is not present'); | ||
|
||
let saveBtnForContact = await driver.findElement(By.id('save-contact-btn')); | ||
let saveBtnTxt = await saveBtnForContact.getText(); | ||
|
||
assert.strictEqual(saveBtnTxt, 'Save', 'Save button is not present'); | ||
let contactNameInputTextBox = await driver.findElement(By.id('contact-name')); | ||
|
||
const checkContactNameEditable = await contactNameInputTextBox.isEnabled(); | ||
assert.strictEqual(checkContactNameEditable, true, 'contact name input text box is not editable'); | ||
|
||
let contactTypeDrpDown = await driver.findElement(By.id('contact-types')); | ||
await contactTypeDrpDown.click(); | ||
let contactTypeDrpDownPresent= await driver.findElement(By.className("dropdown-menu box-shadow contact-options show")); | ||
|
||
assert.strictEqual(await contactTypeDrpDownPresent.isDisplayed(), true, 'contact type dropdown is not displayed'); | ||
|
||
let slackOptionElement = await contactTypeDrpDownPresent.findElement(By.id('option-0')); | ||
await slackOptionElement.click(); | ||
let slackChannelInputTextBox = await driver.findElement(By.id('slack-channel-id')); | ||
const checkSlackChannelEditable = await slackChannelInputTextBox.isEnabled(); | ||
assert.strictEqual(checkSlackChannelEditable, true, 'slack channel input text box is not editable'); | ||
let slackTokenInputTextBox = await driver.findElement(By.id('slack-token')); | ||
const checkSlackTokenEditable = await slackTokenInputTextBox.isEnabled(); | ||
assert.strictEqual(checkSlackTokenEditable, true, 'slack token input text box is not editable'); | ||
|
||
contactTypeDrpDown.click(); | ||
|
||
let webHookOptionElement = await contactTypeDrpDownPresent.findElement(By.id('option-1')); | ||
await webHookOptionElement.click(); | ||
let webHookInputTextBox = await driver.findElement(By.id('webhook-id')); | ||
const checkWebHookEditable = await webHookInputTextBox.isEnabled(); | ||
assert.strictEqual(checkWebHookEditable, true, 'webhook input text box is not editable'); | ||
|
||
let addNewButton = await driver.findElement(By.className('add-new-contact-type btn')); | ||
assert.strictEqual(await addNewButton.getText(), 'Add new contact type', 'Add new button is not present'); | ||
|
||
cancelBtnForContact.click(); | ||
|
||
let notificationMessageInputTextBox = await driver.findElement(By.id('notification-msg')); | ||
const checkMessageEditable = await notificationMessageInputTextBox.isEnabled(); | ||
assert.strictEqual(checkMessageEditable, true, 'notification message input text box is not editable'); | ||
|
||
let labelKeyInputTextBox = await driver.findElement(By.id('label-key')); | ||
const checkLabelKeyEditable = await labelKeyInputTextBox.isEnabled(); | ||
assert.strictEqual(checkLabelKeyEditable, true, 'label key input text box is not editable'); | ||
labelKeyInputTextBox.getAttribute('value').then(function (value) { | ||
assert.strictEqual(value, 'alerting', 'label key input text box is not editable'); | ||
}); | ||
|
||
let labelValueInputTextBox = await driver.findElement(By.id('label-value')); | ||
const checkLabelValueEditable = await labelValueInputTextBox.isEnabled(); | ||
assert.strictEqual(checkLabelValueEditable, true, 'label value input text box is not editable'); | ||
labelValueInputTextBox.getAttribute('value').then(function (value) { | ||
assert.strictEqual(value, 'true', 'label value input text box is not editable'); | ||
}); | ||
|
||
let addNewLabelButton = await driver.findElement(By.className('add-label-container btn')); | ||
assert.strictEqual(await addNewLabelButton.getText(), 'Add Label', 'Add new label button is not present'); | ||
|
||
|
||
// let | ||
// contactTypeDrpDown=await driver.findElement(By.className("dropdown-menu box-shadow contact-type-options show")) | ||
|
||
|
||
|
||
// await contactsPtsBtn.click(); | ||
|
||
} | ||
catch (err) { | ||
// Handle any errors that occur during test execution | ||
console.error(err); | ||
} | ||
finally { | ||
// Close the browser | ||
await driver.quit(); | ||
|
||
} | ||
|
||
} | ||
|
||
testAlertPagesButtons(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please remove the commented code.
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.
I have made the changes for the same