Skip to content
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

Added missing isVisible command in new Element API #4039

Merged
merged 22 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e9eb01c
Added missing isVisible command in new Element API
subhajit20 Feb 22, 2024
d672dde
Added missing isVisible command in new Element API
subhajit20 Feb 22, 2024
73b21ac
Added return type as scopedvalue and removed unwanted changes
subhajit20 Feb 23, 2024
76c985d
Added test for isVisible command
subhajit20 Feb 23, 2024
28fffd5
Added js doc for the command and changed types
subhajit20 Feb 23, 2024
8b8cc77
Added test for visible command
subhajit20 Feb 23, 2024
4b78d85
Added visible command inside command folder
subhajit20 Feb 23, 2024
4d1e0e3
Tested visible command and added test for command
subhajit20 Feb 24, 2024
8273e71
Added a failed test and added since 3.5.0
subhajit20 Feb 26, 2024
b752715
Added successfull and failed test
subhajit20 Feb 26, 2024
0f55dad
Made minor changes on JSDoc and test file
subhajit20 Feb 29, 2024
16e73d6
Removed test
subhajit20 Mar 1, 2024
923c598
Resolving conflicts
subhajit20 Mar 1, 2024
6a15db0
Merge branch 'main' into issue/4037
subhajit20 Mar 1, 2024
fd57d2c
Resolving merge conflicts
subhajit20 Mar 1, 2024
ce6ad30
Added minor formatting changes
subhajit20 Mar 1, 2024
339f65a
Added spaces on 34 and 84 n0 line of ts test file
subhajit20 Mar 1, 2024
91139ca
Added test for isVisisble command
subhajit20 Mar 1, 2024
fe359cf
Added minor changes inside test file of visible command
subhajit20 Mar 1, 2024
634abfd
Fixed test and added aliases of visible command
subhajit20 Mar 2, 2024
0d9352e
Added specification of visible command
subhajit20 Mar 2, 2024
522954b
Fix tests and some refactors.
garg3133 Mar 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions lib/api/web-element/commands/isVisible.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Determines if an element is visible.
*
* For more info on working with DOM elements in Nightwatch, refer to the <a href="https://nightwatchjs.org/guide/writing-tests/finding-interacting-with-dom-elements.html">Finding & interacting with DOM Elements</a> guide page.
*
* @example
* describe('isVisible Demo', function() {
*
* it('test isVisible', function(browser) {
* browser.element('#search')
* .isVisible()
* .assert.equals(true);
* });
*
* it('test async isVisible', async function(browser) {
* const result = await browser.element('#search').isVisible();
* browser.assert.equal(result, true)
subhajit20 marked this conversation as resolved.
Show resolved Hide resolved
* });
*
* after(browser => browser.end());
subhajit20 marked this conversation as resolved.
Show resolved Hide resolved
* });
*
* @since 3.0.0
subhajit20 marked this conversation as resolved.
Show resolved Hide resolved
* @method isVisible
* @memberof ScopedWebElement
* @instance
* @syntax browser.element(selector).isVisible()
* @see https://www.w3.org/TR/webdriver/#element-displayedness
* @returns {ScopedValue<boolean>}
*/
module.exports.command = function () {
return this.runQueuedCommandScoped('isElementDisplayed');
};
41 changes: 41 additions & 0 deletions test/src/api/commands/web-element/testIsVisible.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const assert = require('assert');
const MockServer = require('../../../../lib/mockserver.js');
const CommandGlobals = require('../../../../lib/globals/commands.js');

describe('element().isVisible() command', function() {
subhajit20 marked this conversation as resolved.
Show resolved Hide resolved
before(function (done) {
CommandGlobals.beforeEach.call(this, done);
});

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

it('test .element().isVisible()', function() {
MockServer.addMock({
url: '/wd/hub/session/1352110219202/element/0/visible',
method: 'GET',
response: JSON.stringify({
value: true
})
});

this.client.api.element('#search').isVisible(function (result) {
this.assert.equal(result.value, true);
});
});

it('async test .element().isVisible()', async function() {
MockServer.addMock({
url: '/wd/hub/session/1352110219202/element/0/visible',
method: 'GET',
response: JSON.stringify({
value: true
})
});

const resultPromise = this.client.api.element('#search').isVisible();
const result = await resultPromise;
assert.equal(result, null);
subhajit20 marked this conversation as resolved.
Show resolved Hide resolved
});
});
1 change: 1 addition & 0 deletions types/tests/webElement.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ describe('new element() api', function () {
expectType<ElementValue<string | null>>(elem.getProperty('property-name'));
expectType<ElementValue<string | null>>(elem.getAttribute('attrib-name'));
expectType<ElementValue<string | null>>(elem.getValue());
expectType<ElementValue<boolean>>(elem.isVisible());

expectType<ElementValue<ScopedElementRect>>(elem.getRect());
expectType<ElementValue<ScopedElementRect>>(elem.getSize());
Expand Down
2 changes: 2 additions & 0 deletions types/web-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ export interface ScopedElement extends Element, PromiseLike<WebElement> {
rightClick(): Promise<WebElement>;

waitUntil(signalOrOptions: WaitUntilActions | WaitUntilOptions, waitOptions?: WaitUntilOptions): Promise<WebElement>;

isVisible(): ElementValue<boolean>;
}

type WaitUntilOptions = {
Expand Down
Loading