Skip to content

Commit

Permalink
add isPresent test
Browse files Browse the repository at this point in the history
  • Loading branch information
dikwickley committed Jun 5, 2024
1 parent b0aacb8 commit 4e44f67
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/src/api/commands/web-element/testIsPresent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const assert = require('assert');
const {WebElement} = require('selenium-webdriver');
const MockServer = require('../../../../lib/mockserver.js');
const CommandGlobals = require('../../../../lib/globals/commands-w3c.js');
const common = require('../../../../common.js');
const Element = common.require('element/index.js');

describe('element().isPresent() command', function() {
before(function (done) {
CommandGlobals.beforeEach.call(this, done);
});

after(function (done) {
CommandGlobals.afterEach.call(this, done);
});

it('test .element().isPresent() present', async function() {
const resultPromise = this.client.api.element('#signupSection').isPresent();
assert.strictEqual(resultPromise instanceof Element, false);
assert.strictEqual(typeof resultPromise.find, 'undefined');

assert.strictEqual(resultPromise instanceof Promise, false);
assert.strictEqual(typeof resultPromise.then, 'function');

const result = await resultPromise;
assert.strictEqual(result instanceof WebElement, false);
assert.strictEqual(result, true);

});

it('test .element().isPresent() not present', async function() {
const resultPromise = this.client.api.element('#wrong').isPresent();
assert.strictEqual(resultPromise instanceof Element, false);
assert.strictEqual(typeof resultPromise.find, 'undefined');

assert.strictEqual(resultPromise instanceof Promise, false);
assert.strictEqual(typeof resultPromise.then, 'function');

const result = await resultPromise;
assert.strictEqual(result instanceof WebElement, false);
assert.strictEqual(result, false);

});

});

0 comments on commit 4e44f67

Please sign in to comment.