Skip to content

Commit 73b21ac

Browse files
committed
Added return type as scopedvalue and removed unwanted changes
1 parent c990fc6 commit 73b21ac

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

lib/api/web-element/isVisible.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Returns true if the element is visisble.
3+
*
4+
* 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.
5+
*
6+
* @example
7+
* export default {
8+
* demoTest(browser: NightwatchAPI): void {
9+
* const result = browser.element('#main ul li a.first').isVisible();
10+
* .assert.valueEquals('custom text');
11+
* },
12+
*
13+
* async demoTestAsync(browser: NightwatchAPI): Promise<void> {
14+
* const result = await browser.element('#main ul li a.first').isVisible();
15+
* console.log('element text:', result);
16+
* }
17+
* }
18+
*
19+
* @since 3.0.0
20+
* @method isVisible
21+
* @memberof ScopedWebElement
22+
* @instance
23+
* @syntax browser.element(selector).isVisible()
24+
* @see https://www.w3.org/TR/webdriver#dfn-get-element-text
25+
* @returns {ScopedValue<string>}
26+
*/
27+
module.exports.command = function() {
28+
return this.runQueuedCommandScoped('isElementDisplayed');
29+
};

types/tests/webElement.test-d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ describe('new element() api', function () {
140140
expectType<ElementValue<string | null>>(elem.getProperty('property-name'));
141141
expectType<ElementValue<string | null>>(elem.getAttribute('attrib-name'));
142142
expectType<ElementValue<string | null>>(elem.getValue());
143+
expectType<ElementValue<string | null>>(elem.isVisible());
143144

144145
expectType<ElementValue<ScopedElementRect>>(elem.getRect());
145146
expectType<ElementValue<ScopedElementRect>>(elem.getSize());

types/web-element.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ export interface ScopedElement extends Element, PromiseLike<WebElement> {
188188
rightClick(): Promise<WebElement>;
189189

190190
waitUntil(signalOrOptions: WaitUntilActions | WaitUntilOptions, waitOptions?: WaitUntilOptions): Promise<WebElement>;
191+
192+
isVisible: ElementValue<string | null>;
191193
}
192194

193195
type WaitUntilOptions = {

0 commit comments

Comments
 (0)