Skip to content

Commit

Permalink
[JS] Add code for element information
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha509 committed Oct 14, 2023
1 parent ed89a57 commit 876111b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 15 deletions.
30 changes: 15 additions & 15 deletions examples/javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions examples/javascript/test/elements/information.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const {By, Builder} = require('selenium-webdriver');
const assert = require("assert");

describe('Element Information Test', function () {
let driver;

before(async function () {
driver = await new Builder().forBrowser('chrome').build();
});

beforeEach(async ()=> {
await driver.get('https://www.selenium.dev/selenium/web/inputs.html');
})

it('Check if element is displayed', async function () {
// Resolves Promise and returns boolean value
let result = await driver.findElement(By.name("email_input")).isDisplayed();

assert.equal(result,true);
});

it('Check if button is enabled', async function () {
// Resolves Promise and returns boolean value
let element = await driver.findElement(By.name("button_input")).isEnabled();

assert.equal(element, true);
});

it('Check if checkbox is selected', async function () {
// Returns true if element ins checked else returns false
let isSelected = await driver.findElement(By.name("checkbox_input")).isSelected();

assert.equal(isSelected, true);
});

it('Should return the tagname', async function () {
// Returns TagName of the element
let value = await driver.findElement(By.name('email_input')).getTagName();

assert.equal(value, "input");
});

after(async () => await driver.quit());
});

0 comments on commit 876111b

Please sign in to comment.